|
@ -0,0 +1,52 @@ |
|
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
|
import java.awt.Toolkit; |
|
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JFrame; |
|
|
|
|
|
import javax.swing.JScrollPane; |
|
|
|
|
|
import javax.swing.JTextArea; |
|
|
|
|
|
import javax.swing.JTextField; |
|
|
|
|
|
|
|
|
|
|
|
public class ChatGUI implements ActionListener { |
|
|
|
|
|
|
|
|
|
|
|
JTextField inputTextField = new JTextField(); |
|
|
|
|
|
JTextArea outputTextArea = new JTextArea(); |
|
|
|
|
|
|
|
|
|
|
|
JFrame gui; |
|
|
|
|
|
|
|
|
|
|
|
public ChatGUI() { |
|
|
|
|
|
gui = new JFrame(); |
|
|
|
|
|
|
|
|
|
|
|
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
|
|
|
|
gui.setTitle("java-chat"); |
|
|
|
|
|
|
|
|
|
|
|
gui.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JScrollPane outputScrollPane = new JScrollPane(outputTextArea); |
|
|
|
|
|
gui.add(outputScrollPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
inputTextField.setPreferredSize(new Dimension(0, 30)); |
|
|
|
|
|
gui.add(inputTextField, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
|
|
|
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
|
|
|
|
|
int quarterWidth = screenSize.width / 2; |
|
|
|
|
|
int quarterHeight = screenSize.height / 2; |
|
|
|
|
|
gui.setSize(quarterWidth, quarterHeight); |
|
|
|
|
|
gui.setVisible(true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
|
|
|
|
|
|
new ChatGUI(); |
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
// TODO Auto-generated method stub |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |