320
|
1 package test;
|
|
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 public class ConnectionPanel extends JPanel implements ActionListener{
|
|
11
|
|
12 /**
|
|
13 *
|
|
14 */
|
|
15 private static final long serialVersionUID = 1L;
|
|
16 private JButton button;
|
|
17 private JTextField textField;
|
|
18 public String host;
|
|
19
|
|
20 public ConnectionPanel() {
|
|
21 button = new JButton("Connect");
|
|
22 textField = new JTextField("localhost");
|
|
23
|
|
24 button.setBounds(160, 5, 100, 20);
|
|
25 textField.setBounds(5, 5, 150, 20);
|
|
26
|
|
27 this.setLayout(null);
|
|
28 this.add(textField);
|
|
29 this.add( button);
|
|
30
|
|
31 button.addActionListener(this);
|
|
32 }
|
|
33
|
|
34
|
|
35 public void actionPerformed(ActionEvent event) {
|
|
36 if (event.getSource() == button) {
|
|
37 host = textField.getText();
|
|
38 //System.out.println("pressed!");
|
|
39 }
|
|
40 }
|
|
41
|
|
42 }
|