|
@ -19,18 +19,21 @@ public class ChatGUI implements ActionListener { |
|
|
public ChatGUI() { |
|
|
public ChatGUI() { |
|
|
gui = new JFrame(); |
|
|
gui = new JFrame(); |
|
|
|
|
|
|
|
|
|
|
|
// Set up the main frame |
|
|
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
gui.setTitle("java-chat"); |
|
|
gui.setTitle("java-chat"); |
|
|
|
|
|
|
|
|
gui.setLayout(new BorderLayout()); |
|
|
gui.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set up the output text area with scrolling |
|
|
JScrollPane outputScrollPane = new JScrollPane(outputTextArea); |
|
|
JScrollPane outputScrollPane = new JScrollPane(outputTextArea); |
|
|
gui.add(outputScrollPane, BorderLayout.CENTER); |
|
|
gui.add(outputScrollPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
// Set up the input text field |
|
|
inputTextField.setPreferredSize(new Dimension(0, 30)); |
|
|
inputTextField.setPreferredSize(new Dimension(0, 30)); |
|
|
gui.add(inputTextField, BorderLayout.SOUTH); |
|
|
gui.add(inputTextField, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
|
|
|
|
// Set the size of the GUI to be a quarter of the screen size |
|
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
|
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
|
|
int quarterWidth = screenSize.width / 2; |
|
|
int quarterWidth = screenSize.width / 2; |
|
|
int quarterHeight = screenSize.height / 2; |
|
|
int quarterHeight = screenSize.height / 2; |
|
@ -42,11 +45,11 @@ public class ChatGUI implements ActionListener { |
|
|
|
|
|
|
|
|
new ChatGUI(); |
|
|
new ChatGUI(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
public void actionPerformed(ActionEvent e) { |
|
|
// TODO Auto-generated method stub |
|
|
// TODO Auto-generated method stub |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |