ajout de fenêtres popup pour entrer les informations de l'utilisateur
This commit is contained in:
parent
8e06358109
commit
55f7d26a0f
6 changed files with 79 additions and 51 deletions
|
@ -6,5 +6,10 @@
|
|||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
10
.settings/org.eclipse.jdt.core.prefs
Normal file
10
.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,10 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
BIN
src/chat/ClientWindow.class
Normal file
BIN
src/chat/ClientWindow.class
Normal file
Binary file not shown.
|
@ -53,6 +53,7 @@ class SendThread extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class ReceiveThread extends Thread {
|
||||
|
||||
int port;
|
||||
|
@ -86,7 +87,8 @@ class ReceiveThread extends Thread {
|
|||
}
|
||||
}
|
||||
}
|
||||
public class ClientWindow implements ActionListener {
|
||||
|
||||
/*class PopupWindow implements ActionListener {
|
||||
JFrame popupWindow;
|
||||
JPanel popupPanel;
|
||||
JButton submitButton;
|
||||
|
@ -94,6 +96,46 @@ public class ClientWindow implements ActionListener {
|
|||
JTextField inputField[] = new JTextField[4];
|
||||
JLabel fieldLabel[] = new JLabel[4];
|
||||
|
||||
PopupWindow()
|
||||
{
|
||||
fieldLabel[0] = new JLabel("Destination IP address");
|
||||
fieldLabel[1] = new JLabel("Destination port");
|
||||
fieldLabel[2] = new JLabel("Source port");
|
||||
fieldLabel[3] = new JLabel("Username");
|
||||
|
||||
popupPanel = new JPanel(new GridLayout(5,1));
|
||||
|
||||
for(int i = 0;i < 4; i ++)
|
||||
{
|
||||
inputField[i] = new JTextField();
|
||||
fieldLine[i] = new JPanel(new GridLayout(1,2));
|
||||
fieldLine[i].add(fieldLabel[i]);
|
||||
fieldLine[i].add(inputField[i]);
|
||||
popupPanel.add(fieldLine[i]);
|
||||
}
|
||||
|
||||
submitButton = new JButton("OK");
|
||||
|
||||
popupPanel.add(submitButton);
|
||||
|
||||
popupWindow = new JFrame();
|
||||
popupWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
popupWindow.setSize(new Dimension(640, 480));
|
||||
|
||||
popupWindow.getContentPane().add(popupPanel, BorderLayout.CENTER);
|
||||
|
||||
|
||||
popupWindow.pack();
|
||||
popupWindow.setVisible(true);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
|
||||
}
|
||||
}*/
|
||||
public class ClientWindow implements ActionListener {
|
||||
|
||||
|
||||
JFrame chatWindow;
|
||||
|
||||
|
||||
|
@ -112,35 +154,6 @@ public class ClientWindow implements ActionListener {
|
|||
|
||||
ClientWindow()
|
||||
{
|
||||
fieldLabel[0] = new JLabel("Destination IP address");
|
||||
fieldLabel[1] = new JLabel("Destination port");
|
||||
fieldLabel[2] = new JLabel("Source port");
|
||||
fieldLabel[3] = new JLabel("Username");
|
||||
|
||||
popupPanel = new JPanel(new GridLayout(5,1));
|
||||
|
||||
for(int i = 0;i < 4; i ++)
|
||||
{
|
||||
inputField[i] = new JTextField();
|
||||
fieldLine[i] = new JPanel(new GridLayout(1,2));
|
||||
fieldLine[i].add(fieldLabel[i]);
|
||||
fieldLine[i].add(inputField[i]);
|
||||
popupPanel.add(fieldLine[i]);
|
||||
}
|
||||
|
||||
submitButton = new JButton("OK");
|
||||
popupPanel.add(submitButton);
|
||||
|
||||
popupWindow = new JFrame();
|
||||
popupWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
popupWindow.setSize(new Dimension(640, 480));
|
||||
|
||||
popupWindow.getContentPane().add(popupPanel, BorderLayout.CENTER);
|
||||
|
||||
popupWindow.pack();
|
||||
popupWindow.setVisible(true);
|
||||
|
||||
|
||||
chatWindow = new JFrame("Système de clavardage 2.0.1");
|
||||
|
||||
chatPanel = new JPanel(new GridLayout(2, 2));
|
||||
|
@ -163,36 +176,36 @@ public class ClientWindow implements ActionListener {
|
|||
chatText.setLineWrap(true);
|
||||
chatText.setEditable(false);
|
||||
|
||||
|
||||
chatPanel.add(textScroll);
|
||||
chatPanel.add(sendPanel);
|
||||
chatPanel.add(sendPanel, BorderLayout.SOUTH);
|
||||
|
||||
chatWindow.getContentPane().add(chatPanel, BorderLayout.CENTER);
|
||||
|
||||
|
||||
//Display the window.
|
||||
|
||||
|
||||
address = JOptionPane.showInputDialog(chatWindow,
|
||||
"Enter the destination address",
|
||||
"POPOPOPOPUPUPOPOPUP",
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
sport = Integer.parseInt(JOptionPane.showInputDialog(chatWindow,
|
||||
"Enter the source port",
|
||||
"POPOPOPOPUPUPOPOPUP",
|
||||
JOptionPane.PLAIN_MESSAGE));
|
||||
dport = Integer.parseInt(JOptionPane.showInputDialog(chatWindow,
|
||||
"Enter the destination port",
|
||||
"POPOPOPOPUPUPOPOPUP",
|
||||
JOptionPane.PLAIN_MESSAGE));
|
||||
username = JOptionPane.showInputDialog(chatWindow,
|
||||
"Enter a username",
|
||||
"POPOPOPOPUPUPOPOPUP",
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
chatWindow.pack();
|
||||
chatWindow.setVisible(true);
|
||||
|
||||
try
|
||||
{
|
||||
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
|
||||
System.out.print("Entrez l'adresse de destination:");
|
||||
address = console.readLine();
|
||||
System.out.print("Entrez le numéro de port source:");
|
||||
sport = Integer.parseInt(console.readLine());
|
||||
System.out.print("Entrez le numéro de port destination:");
|
||||
dport = Integer.parseInt(console.readLine());
|
||||
System.out.print("Entrez votre nom d'utilisateur:");
|
||||
username = console.readLine();
|
||||
|
||||
ReceiveThread t2 = new ReceiveThread(sport, chatText);
|
||||
t2.start();
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
System.out.println("nik3!");
|
||||
}
|
||||
ReceiveThread t2 = new ReceiveThread(sport, chatText);
|
||||
t2.start();
|
||||
}
|
||||
public static void main (String [] args)
|
||||
{
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue