Mercurial > hg > Applications > TreeVNC
annotate src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncRootSelectionPanel.java @ 232:6ee4cdca104c
send value of port and localhost in checkdelay framebufferupdate, and get this.
author | oc |
---|---|
date | Fri, 10 Oct 2014 23:39:44 +0900 |
parents | 2b3eb4a9492f |
children | 7d8f45cadd89 |
rev | line source |
---|---|
206 | 1 package jp.ac.u_ryukyu.treevnc; |
1 | 2 |
3 import javax.swing.*; | |
130 | 4 |
5 import com.glavsoft.viewer.swing.ConnectionParams; | |
6 | |
1 | 7 import java.awt.*; |
8 import java.awt.event.*; | |
130 | 9 |
129 | 10 public class TreeVncRootSelectionPanel extends JFrame implements ActionListener, |
1 | 11 ItemListener { |
12 | |
13 /** | |
14 * | |
15 */ | |
16 private static final long serialVersionUID = 1L; | |
17 private JPanel panel = new JPanel(); | |
18 private JButton button = new JButton("Connect"); | |
19 private TextField t1; | |
20 private TextField t2; | |
21 private double width = 750; | |
22 private double height = 500; | |
23 private JLabel label; | |
24 private boolean flag; | |
25 private int counter = 0; | |
26 // private JCheckBox[] check = new JCheckBox[20]; | |
27 private Checkbox[] check = new Checkbox[20]; | |
28 private String port; | |
29 private CheckboxGroup ch = new CheckboxGroup(); | |
32 | 30 private Container contentPane = getContentPane(); |
130 | 31 private CreateConnectionParam cp; |
1 | 32 |
129 | 33 public TreeVncRootSelectionPanel() { |
78
fc984746f958
use real ip address for TreeVNC root selection
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
34 setTitle("TreeVNC Root Address"); |
1 | 35 setResizable(false); |
36 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
37 } | |
38 | |
39 public void ipRegister() { | |
40 setSize(); | |
41 setText(); | |
2
dca3bd61b830
before change MyVncClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
42 setButton(); |
1 | 43 visible(); |
44 } | |
45 | |
46 private void setSize() { | |
47 Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); | |
48 width = (d.getWidth() / 2); | |
49 height = (d.getHeight() / 2); | |
50 } | |
51 | |
2
dca3bd61b830
before change MyVncClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
52 public void visible() { |
1 | 53 Point point = new Point(); |
54 point.setLocation(width - 250, height - 80); | |
55 setLocation(point.getLocation()); | |
56 pack(); | |
57 setVisible(true); | |
58 } | |
59 | |
60 public void unVisible() { | |
61 setVisible(false); | |
62 } | |
63 | |
2
dca3bd61b830
before change MyVncClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
64 private void setText() { |
1 | 65 t1 = new TextField("Address", 30); |
130 | 66 t2 = new TextField(Integer.toString(ConnectionParams.DEFAULT_VNC_ROOT), 5); |
1 | 67 panel.add(t1); |
68 panel.add(t2); | |
2
dca3bd61b830
before change MyVncClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
69 //panel.add(button); |
dca3bd61b830
before change MyVncClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
70 //button.addActionListener(this); |
1 | 71 label = new JLabel(); |
72 contentPane.add(panel, BorderLayout.CENTER); | |
73 contentPane.add(label, BorderLayout.SOUTH); | |
74 } | |
75 | |
2
dca3bd61b830
before change MyVncClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
76 public void checkBox(String str) { |
1 | 77 if (counter == 0) |
78 check[counter] = new Checkbox(str, true, ch); | |
79 else | |
80 check[counter] = new Checkbox(str, false, ch); | |
81 check[counter].addItemListener(this); | |
82 panel.add(check[counter]); | |
83 panel.setLayout(new GridLayout(counter + 2, 0)); | |
84 panel.setLocation((int) width - 250, (int) height - 80); | |
85 counter++; | |
86 } | |
87 | |
88 public void setButton() { | |
89 panel.add(button); | |
90 button.addActionListener(this); | |
91 contentPane.add(panel, BorderLayout.CENTER); | |
92 } | |
93 | |
94 public String getAddressOption() { | |
95 while (!(flag)) { | |
96 try { | |
97 Thread.sleep(500); | |
98 } catch (InterruptedException e) { | |
99 e.printStackTrace(); | |
100 } | |
101 } | |
102 return t1.getText(); | |
103 } | |
104 | |
105 public String getPortOption() { | |
106 return t2.getText(); | |
107 } | |
108 | |
109 public String getPort() { | |
110 return port; | |
111 } | |
112 | |
113 public void actionPerformed(ActionEvent e) { | |
114 flag = true; | |
115 for (int t = 0; t < counter; t++) { | |
116 if (check[t].getState()) { | |
117 System.out.println(check[t].getLabel()); | |
145
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
118 String str = check[t].getLabel(); |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
119 String[] temp = str.split(":"); |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
120 String port = temp[0]; |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
121 String hostAddress = temp[1]; |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
122 String rootAddress = temp[2]; |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
123 cp.setHostName(hostAddress,Integer.parseInt(port),rootAddress); |
649794dfb9d5
add my hostname to handle multiple network
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
144
diff
changeset
|
124 unVisible(); |
1 | 125 } |
126 } | |
127 } | |
128 | |
129 | |
130 public void itemStateChanged(ItemEvent e) { | |
131 } | |
130 | 132 |
133 public void setCp(CreateConnectionParam cp) { | |
134 this.cp = cp; | |
135 } | |
1 | 136 } |