102
|
1 package myVncClient;
|
|
2
|
|
3 import javax.swing.*;
|
|
4 import java.awt.*;
|
|
5 import java.awt.event.*;
|
|
6
|
|
7 public class TextBox extends JFrame implements ActionListener {
|
|
8
|
|
9 JPanel panel = new JPanel();
|
|
10 JButton button = new JButton("Connect");
|
|
11 TextField t1;
|
|
12 TextField t2;
|
|
13 double width;
|
|
14 double height;
|
|
15 JLabel label;
|
|
16 boolean flag;
|
|
17
|
|
18 public void ipRegister() {
|
|
19 setSize();
|
|
20 setText();
|
|
21 visible();
|
|
22 }
|
|
23
|
|
24 public TextBox() {
|
|
25 setTitle("Informatin Connection Address");
|
|
26 setResizable(false);
|
|
27 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
28 }
|
|
29
|
|
30 void setSize() {
|
|
31 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
|
|
32 width = (d.getWidth() / 2);
|
|
33 height = (d.getHeight() / 2);
|
|
34 }
|
|
35
|
|
36 void visible() {
|
|
37 Point point = new Point();
|
|
38 point.setLocation(width - 250, height - 80);
|
|
39 setLocation(point.getLocation());
|
|
40 pack();
|
|
41 setVisible(true);
|
|
42 }
|
|
43
|
|
44 void setText() {
|
104
|
45 t1 = new TextField("dimolto.cr.ie.u-ryukyu.ac.jp", 30);
|
|
46 t2 = new TextField("5999", 5);
|
102
|
47 panel.add(t1);
|
|
48 panel.add(t2);
|
|
49 panel.add(button);
|
|
50 button.addActionListener(this);
|
|
51 label = new JLabel();
|
|
52 Container contentPane = getContentPane();
|
|
53 contentPane.add(panel, BorderLayout.CENTER);
|
|
54 contentPane.add(label, BorderLayout.SOUTH);
|
|
55 }
|
|
56
|
|
57 public String getAddress() {
|
|
58 while(!(flag)) {
|
|
59 try {
|
|
60 Thread.sleep(500);
|
|
61 } catch (InterruptedException e) {
|
|
62 e.printStackTrace();
|
|
63 }
|
|
64 }
|
|
65 return t1.getText();
|
|
66 }
|
|
67 public String getPort() {
|
|
68 return t2.getText();
|
|
69 }
|
|
70
|
|
71 public void actionPerformed(ActionEvent e) {
|
|
72 flag = true;
|
|
73 }
|
|
74 }
|