Mercurial > hg > Members > you > TreeVNC
annotate src/treeVnc/TextBoxProxy.java @ 21:810c53d66376
remove warning (Before the modifying)
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Jan 2012 16:13:09 +0900 |
parents | 578ea14c95e9 |
children | 24112133a0d9 |
rev | line source |
---|---|
15 | 1 package treeVnc; |
2 | |
3 import javax.swing.*; | |
4 import java.awt.*; | |
5 import java.awt.event.*; | |
6 | |
7 public class TextBoxProxy extends JFrame implements ActionListener { | |
8 | |
21
810c53d66376
remove warning (Before the modifying)
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
15
diff
changeset
|
9 /** |
810c53d66376
remove warning (Before the modifying)
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
15
diff
changeset
|
10 * |
810c53d66376
remove warning (Before the modifying)
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
15
diff
changeset
|
11 */ |
810c53d66376
remove warning (Before the modifying)
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
15
diff
changeset
|
12 private static final long serialVersionUID = 1L; |
15 | 13 private JPanel panel; |
14 private JButton button; | |
15 private JButton button1; | |
16 private TextField t1; | |
17 private TextField t2; | |
18 private JPasswordField pw; | |
19 private double width; | |
20 private double height; | |
21 private JLabel label; | |
22 private boolean flag; | |
23 private VncProxyService vps; | |
24 | |
25 public void ipRegister() { | |
26 setSize(); | |
27 setText(); | |
28 visible(); | |
29 } | |
30 | |
31 public TextBoxProxy(VncProxyService _vps) { | |
32 vps = _vps; | |
33 setTitle("Informatin Connection Address"); | |
34 setResizable(false); | |
35 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
36 } | |
37 | |
38 private void setSize() { | |
39 Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); | |
40 width = (d.getWidth() / 2); | |
41 height = (d.getHeight() / 2); | |
42 } | |
43 | |
44 private void visible() { | |
45 Point point = new Point(); | |
46 point.setLocation(width - 250, height - 80); | |
47 setLocation(point.getLocation()); | |
48 pack(); | |
49 setVisible(true); | |
50 } | |
51 | |
52 private void init(){ | |
53 frameInit(); | |
54 // panel = null; | |
55 // button = null; | |
56 // label = null; | |
57 setVisible(false); | |
58 } | |
59 | |
60 public void changeHost() { | |
61 init(); | |
62 button1 = new JButton("Change Host"); | |
63 t1 = new TextField("Address", 30); | |
64 panel = new JPanel(); | |
65 panel.add(t1); | |
66 panel.add(button1); | |
67 button1.addActionListener(this); | |
68 label = new JLabel(); | |
69 Container contentPane = getContentPane(); | |
70 contentPane.add(panel, BorderLayout.CENTER); | |
71 contentPane.add(label, BorderLayout.SOUTH); | |
72 visible(); | |
73 } | |
74 | |
75 private void setText() { | |
76 panel = new JPanel(); | |
77 t1 = new TextField("localhost", 30); | |
78 t2 = new TextField("5900", 5); | |
79 pw = new JPasswordField("Password",30); | |
80 button = new JButton("Connect"); | |
81 panel.add(t1); | |
82 panel.add(t2); | |
83 panel.add(pw); | |
84 panel.add(button); | |
85 button.addActionListener(this); | |
86 label = new JLabel(); | |
87 Container contentPane = getContentPane(); | |
88 contentPane.add(panel, BorderLayout.CENTER); | |
89 contentPane.add(label, BorderLayout.SOUTH); | |
90 } | |
91 | |
92 public String getAddress() { | |
93 while(!(flag)) { | |
94 try { | |
95 Thread.sleep(500); | |
96 } catch (InterruptedException e) { | |
97 e.printStackTrace(); | |
98 } | |
99 } | |
100 return t1.getText(); | |
101 } | |
102 public String getPort() { | |
103 return t2.getText(); | |
104 } | |
105 | |
106 public String getPassword() { | |
107 return String.valueOf(pw.getPassword()); | |
108 } | |
109 | |
110 public void actionPerformed(ActionEvent e) { | |
111 if(e.getSource()==button) { | |
112 flag = true; | |
113 setVisible(false); | |
114 } | |
115 if(e.getSource()==button1) | |
116 try { | |
117 init(); | |
118 vps.host = getAddress(); | |
119 vps.changeInit(); | |
120 } catch (Exception e1) { | |
121 e1.printStackTrace(); | |
122 } | |
123 } | |
124 } |