5
|
1 package rep.gui;
|
|
2
|
|
3 import java.awt.event.ActionEvent;
|
|
4 import java.awt.event.ActionListener;
|
|
5
|
|
6 import javax.swing.JButton;
|
|
7 import javax.swing.JPanel;
|
|
8 import javax.swing.JTextField;
|
|
9
|
|
10 import rep.ConnectionListener;
|
|
11
|
|
12 public class ConnectionPanel extends JPanel implements ActionListener{
|
|
13
|
133
|
14 /**
|
|
15 *
|
|
16 */
|
|
17 private static final long serialVersionUID = 1L;
|
5
|
18 private JButton button;
|
|
19 private JTextField textField;
|
133
|
20 public String host;
|
5
|
21
|
|
22 public ConnectionPanel(ConnectionListener connectionlistener){
|
|
23 button = new JButton("Connect");
|
|
24 textField = new JTextField("localhost");
|
|
25
|
|
26 button.setBounds(160, 5, 100, 20);
|
|
27 textField.setBounds(5, 5, 150, 20);
|
|
28
|
|
29 this.setLayout(null);
|
|
30 this.add(textField);
|
|
31 this.add( button);
|
|
32
|
|
33 button.addActionListener(this);
|
|
34 }
|
|
35
|
|
36
|
|
37 public ConnectionPanel() {
|
|
38 button = new JButton("Connect");
|
|
39 textField = new JTextField("localhost");
|
|
40
|
|
41 button.setBounds(160, 5, 100, 20);
|
|
42 textField.setBounds(5, 5, 150, 20);
|
|
43
|
|
44 this.setLayout(null);
|
|
45 this.add(textField);
|
|
46 this.add( button);
|
|
47
|
|
48 button.addActionListener(this);
|
|
49 }
|
|
50
|
|
51
|
|
52 public void actionPerformed(ActionEvent event) {
|
|
53 // TODO Auto-generated method stub
|
|
54 if (event.getSource() == button) {
|
|
55 host = textField.getText();
|
|
56 System.out.println("pressed!");
|
|
57 }
|
|
58 }
|
|
59
|
|
60 }
|