updated some gui stuff
This commit is contained in:
parent
5e805a4cc5
commit
6971caf831
@ -14,6 +14,8 @@ import javax.swing.JButton;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class ClientGUI extends JFrame {
|
||||
|
||||
@ -83,8 +85,11 @@ public class ClientGUI extends JFrame {
|
||||
btnPop.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
String received = client.pop();
|
||||
textPane.setText(textPane.getText() + received);
|
||||
String time = sdf.format(new Date()) + ": ";
|
||||
textPane.setText(textPane.getText() + time + received + "\n");
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
@ -114,11 +119,11 @@ public class ClientGUI extends JFrame {
|
||||
contentPane.add(lblPort);
|
||||
|
||||
final JLabel serverInformation = new JLabel("");
|
||||
serverInformation.setBounds(300, 20, 130, 28);
|
||||
serverInformation.setBounds(260, 20, 184, 28);
|
||||
contentPane.add(serverInformation);
|
||||
|
||||
JButton btnConnectToServer = new JButton("Connect to Server");
|
||||
btnConnectToServer.addActionListener(new ActionListener() {
|
||||
JButton listenToPort = new JButton("Listen to port");
|
||||
listenToPort.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
port = -1;
|
||||
boolean portOkay = false;
|
||||
@ -139,8 +144,8 @@ public class ClientGUI extends JFrame {
|
||||
if (portOkay) {
|
||||
try {
|
||||
client = new NetworkClient("localhost", port);
|
||||
serverInformation.setForeground(Color.GREEN);
|
||||
serverInformation.setText("connected!");
|
||||
serverInformation.setForeground(Color.BLUE);
|
||||
serverInformation.setText("listening to port " + port +"!");
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
@ -149,8 +154,8 @@ public class ClientGUI extends JFrame {
|
||||
|
||||
}
|
||||
});
|
||||
btnConnectToServer.setBounds(127, 19, 165, 29);
|
||||
contentPane.add(btnConnectToServer);
|
||||
listenToPort.setBounds(114, 21, 146, 29);
|
||||
contentPane.add(listenToPort);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user