Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Client extends JFrame implements ActionListener
- {
- private JButton button;
- private JTextField textfield;
- public Client()
- {
- super("Test");
- JPanel pane = new JPanel();
- pane.setLayout(new FlowLayout());
- textfield = new JTextField("TextField");
- button = new JButton("Button");
- button.addActionListener(this);
- pane.add(textfield);
- pane.add(button);
- setContentPane(pane);
- }
- public void actionPerformed(ActionEvent event)
- {
- Object e = event.getSource();
- if (e == button)
- {
- textfield.setText("Anderer Text");
- try
- {
- Socket client = new Socket("localhost", 12345);
- }
- catch (Exception ex)
- {
- JOptionPane.showMessageDialog(null, "Server nicht erreichbar");
- }
- }
- }
- public static void main(String[] args) throws UnknownHostException, IOException
- {
- Client frame = new Client();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setSize(300, 300);
- frame.setResizable(false);
- frame.setVisible(true);
- }
- }
- // Ja, ich gebe zu... die GUI ist echt grausig umgesetzt...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement