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