création d'une fenêtre popup pour entrer les paramètres du programme

This commit is contained in:
Louis Farina 2020-12-03 12:23:42 +01:00
parent 3a8a8ef7f1
commit 8e06358109

View file

@ -87,8 +87,16 @@ class ReceiveThread extends Thread {
}
}
public class ClientWindow implements ActionListener {
JFrame popupWindow;
JPanel popupPanel;
JButton submitButton;
JPanel fieldLine[] = new JPanel[4];
JTextField inputField[] = new JTextField[4];
JLabel fieldLabel[] = new JLabel[4];
JFrame chatWindow;
JPanel chatPanel;
JTextArea chatText;
JScrollPane textScroll;
@ -104,8 +112,35 @@ public class ClientWindow implements ActionListener {
ClientWindow()
{
/* System.out.println("Connecting to server...");
System.out.println("Establishing I/O streams...");*/
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));
@ -162,7 +197,7 @@ public class ClientWindow implements ActionListener {
public static void main (String [] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
ClientWindow window = new ClientWindow();
}