178
|
1 package myVncProxy;
|
|
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 JPasswordField pw;
|
|
14 double width;
|
|
15 double height;
|
|
16 JLabel label;
|
|
17 boolean flag;
|
|
18
|
|
19 public void ipRegister() {
|
|
20 setSize();
|
|
21 setText();
|
|
22 visible();
|
|
23 }
|
|
24
|
|
25 public TextBox() {
|
|
26 setTitle("Informatin Connection Address");
|
|
27 setResizable(false);
|
|
28 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
29 }
|
|
30
|
|
31 void setSize() {
|
|
32 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
|
|
33 width = (d.getWidth() / 2);
|
|
34 height = (d.getHeight() / 2);
|
|
35 }
|
|
36
|
|
37 void visible() {
|
|
38 Point point = new Point();
|
|
39 point.setLocation(width - 250, height - 80);
|
|
40 setLocation(point.getLocation());
|
|
41 pack();
|
|
42 setVisible(true);
|
|
43 }
|
|
44
|
|
45 void setText() {
|
|
46 t1 = new TextField("you.st.ie.u-ryukyu.ac.jp", 30);
|
|
47 t2 = new TextField("5900", 5);
|
|
48 pw = new JPasswordField("kakiku");
|
|
49 panel.add(t1);
|
|
50 panel.add(t2);
|
|
51 panel.add(pw);
|
|
52 panel.add(button);
|
|
53 button.addActionListener(this);
|
|
54 label = new JLabel();
|
|
55 Container contentPane = getContentPane();
|
|
56 contentPane.add(panel, BorderLayout.CENTER);
|
|
57 contentPane.add(label, BorderLayout.SOUTH);
|
|
58 }
|
|
59
|
|
60 public String getAddress() {
|
|
61 while(!(flag)) {
|
|
62 try {
|
|
63 Thread.sleep(500);
|
|
64 } catch (InterruptedException e) {
|
|
65 e.printStackTrace();
|
|
66 }
|
|
67 }
|
|
68 return t1.getText();
|
|
69 }
|
|
70 public String getPort() {
|
|
71 return t2.getText();
|
|
72 }
|
|
73
|
|
74 public String getPassword() {
|
|
75 return String.valueOf(pw.getPassword());
|
|
76 }
|
|
77
|
|
78 public void actionPerformed(ActionEvent e) {
|
|
79 flag = true;
|
|
80 }
|
|
81 } |