Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by Eugene Saun ( 15 years ago )
import java.awt.ScrollPane;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Client extends Frame implements ActionListener {
private static final int w = 480;
private static final int h = 320;
TextArea inbox;
TextArea outbox;
Button send;
Button close;
public Client() {
/*
GUI
*/
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
setBounds((int) (screenSize.width - w)/2, (int) (screenSize.height - h)/2, w, h);
inbox = new TextArea();
inbox.setEditable(false);
outbox = new TextArea();
send = new Button("Send");
send.addActionListener(this);
close = new Button("Close");
close.addActionListener(this);
Panel buttons = new Panel(new GridLayout(0, 1, 10, 10));
buttons.add(send);
buttons.add(close);
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.gridwidth = 2;
c.gridheight = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(5, 5, 5, 5);
c.anchor = GridBagConstraints.FIRST_LINE_START;
c.weightx = 1;
c.weighty = 1;
add(inbox, c);
c.gridx = 0;
c.gridy = 1;
c.gridwidth = 1;
c.gridheight = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(5, 5, 5, 5);
c.anchor = GridBagConstraints.FIRST_LINE_START;
c.weightx = 1;
c.weighty = 1;
add(outbox, c);
c.gridx = 1;
c.gridy = 1;
c.gridwidth = 1;
c.gridheight = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(5, 5, 5, 5);
c.anchor = GridBagConstraints.FIRST_LINE_START;
c.weightx = 1;
c.weighty = 1;
add(buttons, c);
setUndecorated(false);
setTitle("JRE Client");
/*
Network
*/
}
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == send) {
//TO DO:
} else if (source == close) {
dispose();
System.exit(0);
}
}
public static void main(String[] args) {
Client c = new Client();
c.pack();
c.setVisible(true);
c.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
// Exit the application
System.exit(0);
}
});
}
}
Revise this Paste