Mercurial > hg > Members > you > TreeVNC
annotate src/treeVnc/TextBoxClient.java @ 62:b2492abdae2a Version1.0 tip
Added tag TreeVNC_version1.0 for changeset 318ec7415073
author | Taninari YU <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 12 Aug 2012 22:13:39 +0900 |
parents | 32b266967c2c |
children |
rev | line source |
---|---|
15 | 1 package treeVnc; |
2 | |
3 import javax.swing.*; | |
4 import java.awt.*; | |
5 import java.awt.event.*; | |
6 import java.util.ArrayList; | |
7 | |
27 | 8 public class TextBoxClient extends JFrame implements ActionListener, |
9 ItemListener { | |
15 | 10 |
21
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 * |
810c53d66376
remove warning (Before the modifying)
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
15
diff
changeset
|
13 */ |
810c53d66376
remove warning (Before the modifying)
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
15
diff
changeset
|
14 private static final long serialVersionUID = 1L; |
15 | 15 private JPanel panel = new JPanel(); |
16 private JButton button = new JButton("Connect"); | |
17 private TextField t1; | |
18 private TextField t2; | |
19 private double width = 750; | |
20 private double height = 500; | |
21 private JLabel label; | |
22 private boolean flag; | |
24 | 23 private ArrayList<String> temp = new ArrayList<String>(); |
15 | 24 private int counter = 0; |
27 | 25 // private JCheckBox[] check = new JCheckBox[20]; |
15 | 26 private Checkbox[] check = new Checkbox[20]; |
27 private boolean firstFlag = true; | |
28 private String hostAddress; | |
29 private String port; | |
30 private CheckboxGroup ch = new CheckboxGroup(); | |
27 | 31 |
22
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
32 public TextBoxClient() { |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
33 setTitle("Informatin Connection Address"); |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
34 setResizable(false); |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
35 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
36 } |
15 | 37 |
38 public void ipRegister() { | |
39 setSize(); | |
40 setText(); | |
41 visible(); | |
42 } | |
43 | |
44 private void setSize() { | |
45 Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); | |
46 width = (d.getWidth() / 2); | |
47 height = (d.getHeight() / 2); | |
48 } | |
49 | |
50 void visible() { | |
51 Point point = new Point(); | |
52 point.setLocation(width - 250, height - 80); | |
53 setLocation(point.getLocation()); | |
54 pack(); | |
55 setVisible(true); | |
56 } | |
57 | |
58 public void unVisible() { | |
59 setVisible(false); | |
60 } | |
61 | |
62 private void setText() { | |
63 t1 = new TextField("Address", 30); | |
64 t2 = new TextField("5999", 5); | |
65 panel.add(t1); | |
66 panel.add(t2); | |
67 panel.add(button); | |
68 button.addActionListener(this); | |
69 label = new JLabel(); | |
70 Container contentPane = getContentPane(); | |
71 contentPane.add(panel, BorderLayout.CENTER); | |
72 contentPane.add(label, BorderLayout.SOUTH); | |
73 } | |
74 | |
75 void checkBox(String str) { | |
27 | 76 // CheckboxGroup ch = new CheckboxGroup(); |
15 | 77 if (counter == 0) |
27 | 78 check[counter] = new Checkbox(str, true, ch); |
15 | 79 else |
27 | 80 check[counter] = new Checkbox(str, false, ch); |
81 // check[counter].setBackground(new Color(0, 153, 255)); | |
15 | 82 check[counter].addItemListener(this); |
83 panel.add(check[counter]); | |
84 panel.setLayout(new GridLayout(counter + 2, 0)); | |
85 panel.setLocation((int) width - 250, (int) height - 80); | |
86 counter++; | |
87 } | |
88 | |
31 | 89 public void setButton() { |
15 | 90 panel.add(button); |
27 | 91 // panel.setBackground(Color.blue); |
15 | 92 button.addActionListener(this); |
93 Container contentPane = getContentPane(); | |
94 contentPane.add(panel, BorderLayout.CENTER); | |
95 } | |
96 | |
97 private void reportWindow() { | |
98 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
99 Container pane = getContentPane(); | |
27 | 100 JLabel label = new JLabel( |
101 "Not found Proxy. If you use Client-mode you must set-up Proxy"); | |
102 label.setPreferredSize(new Dimension(580, 50)); | |
15 | 103 label.setFont(new Font("Arial", Font.PLAIN, 20)); |
104 pane.add(label); | |
105 } | |
27 | 106 |
22
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
107 public String getAddressOption() { |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
108 while (!(flag)) { |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
109 try { |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
110 Thread.sleep(500); |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
111 } catch (InterruptedException e) { |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
112 e.printStackTrace(); |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
113 } |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
114 } |
27 | 115 return t1.getText(); |
22
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
116 } |
15 | 117 |
118 public String getAddress() { | |
119 int i = 0; | |
120 while (!(flag)) { | |
27 | 121 if (i >= 50) { |
34
32b266967c2c
delete notfound window
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
31
diff
changeset
|
122 /* |
15 | 123 reportWindow(); |
124 visible(); | |
125 break; | |
34
32b266967c2c
delete notfound window
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
31
diff
changeset
|
126 */ |
32b266967c2c
delete notfound window
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
31
diff
changeset
|
127 return "notFound"; |
15 | 128 } |
129 try { | |
130 Thread.sleep(500); | |
131 } catch (InterruptedException e) { | |
132 e.printStackTrace(); | |
133 } | |
134 i++; | |
135 } | |
136 return hostAddress; | |
137 // return t1.getText(); | |
138 } | |
27 | 139 |
22
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
140 public String getPortOption() { |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
141 return t2.getText(); |
24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
21
diff
changeset
|
142 } |
27 | 143 |
15 | 144 public String getPort() { |
145 return port; | |
146 // return t2.getText(); | |
147 } | |
148 | |
149 public void actionPerformed(ActionEvent e) { | |
150 flag = true; | |
151 for (int t = 0; t < counter; t++) { | |
152 if (check[t].getState()) { | |
153 System.out.println(check[t].getLabel()); | |
27 | 154 // if(int t =0) |
155 setStatus(check[t].getLabel()); | |
156 unVisible(); | |
157 // else | |
158 // setStatus() | |
15 | 159 } |
160 } | |
161 } | |
162 | |
163 private void setStatus(String str) { | |
164 String[] temp = str.split(":"); | |
27 | 165 if (temp.length == 2) { |
166 hostAddress = temp[0]; | |
167 port = temp[1]; | |
168 } else { | |
169 port = temp[0]; | |
170 System.out.println("port=" + port); | |
171 hostAddress = temp[3]; | |
172 } | |
15 | 173 } |
27 | 174 |
15 | 175 String splitString(String str) { |
176 String[] split = str.split("\\*"); | |
177 String comper; | |
178 if (split.length > 4) { | |
179 split[4] = null; | |
180 } | |
181 comper = split[1] + split[3]; | |
182 if (firstFlag) { | |
183 temp.add(comper); | |
184 firstFlag = false; | |
27 | 185 return "port:" + split[0] + ":host:" + split[1] + ":proxy:" |
186 + split[3]; | |
15 | 187 } |
188 for (int t = 0; t < temp.size(); t++) { | |
189 if (!(comper.equals(temp.get(t)))) { | |
190 if (t == temp.size() - 1) { | |
191 temp.add(comper); | |
27 | 192 return "port:" + split[0] + ":host:" + split[1] + ":proxy:" |
193 + split[3]; | |
15 | 194 } |
195 } else { | |
196 break; | |
197 } | |
198 } | |
199 return null; | |
200 } | |
201 | |
202 public void itemStateChanged(ItemEvent e) { | |
203 } | |
204 } |