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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
206
2b3eb4a9492f MyRfbProto reorganization
oc
parents: 156
diff changeset
1 package jp.ac.u_ryukyu.treevnc;
1
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 import javax.swing.*;
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
4
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
5 import com.glavsoft.viewer.swing.ConnectionParams;
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
6
1
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 import java.awt.*;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 import java.awt.event.*;
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
9
129
a6dc674546f2 change connection param expression timing.
oc
parents: 79
diff changeset
10 public class TreeVncRootSelectionPanel extends JFrame implements ActionListener,
1
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 ItemListener {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 /**
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 *
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 */
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 private static final long serialVersionUID = 1L;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 private JPanel panel = new JPanel();
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 private JButton button = new JButton("Connect");
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 private TextField t1;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 private TextField t2;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 private double width = 750;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 private double height = 500;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 private JLabel label;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 private boolean flag;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 private int counter = 0;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 // private JCheckBox[] check = new JCheckBox[20];
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 private Checkbox[] check = new Checkbox[20];
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 private String port;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 private CheckboxGroup ch = new CheckboxGroup();
32
758d025ee24b add TextBox.java
one
parents: 28
diff changeset
30 private Container contentPane = getContentPane();
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
31 private CreateConnectionParam cp;
1
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32
129
a6dc674546f2 change connection param expression timing.
oc
parents: 79
diff changeset
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
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 setResizable(false);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 public void ipRegister() {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 setSize();
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 setText();
2
dca3bd61b830 before change MyVncClient.java
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents: 1
diff changeset
42 setButton();
1
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 visible();
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 private void setSize() {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 width = (d.getWidth() / 2);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 height = (d.getHeight() / 2);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 Point point = new Point();
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 point.setLocation(width - 250, height - 80);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 setLocation(point.getLocation());
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 pack();
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 setVisible(true);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 public void unVisible() {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 setVisible(false);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 t1 = new TextField("Address", 30);
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
66 t2 = new TextField(Integer.toString(ConnectionParams.DEFAULT_VNC_ROOT), 5);
1
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 panel.add(t1);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 label = new JLabel();
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 contentPane.add(panel, BorderLayout.CENTER);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 contentPane.add(label, BorderLayout.SOUTH);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 if (counter == 0)
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 check[counter] = new Checkbox(str, true, ch);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 else
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 check[counter] = new Checkbox(str, false, ch);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 check[counter].addItemListener(this);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 panel.add(check[counter]);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 panel.setLayout(new GridLayout(counter + 2, 0));
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 panel.setLocation((int) width - 250, (int) height - 80);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 counter++;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 public void setButton() {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 panel.add(button);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 button.addActionListener(this);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 contentPane.add(panel, BorderLayout.CENTER);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 public String getAddressOption() {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 while (!(flag)) {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 try {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 Thread.sleep(500);
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 } catch (InterruptedException e) {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 e.printStackTrace();
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 return t1.getText();
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 public String getPortOption() {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 return t2.getText();
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 public String getPort() {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 return port;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 public void actionPerformed(ActionEvent e) {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 flag = true;
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 for (int t = 0; t < counter; t++) {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 if (check[t].getState()) {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
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
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 }
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 public void itemStateChanged(ItemEvent e) {
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 }
130
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
132
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
133 public void setCp(CreateConnectionParam cp) {
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
134 this.cp = cp;
1f6bfaa3281b root selection panel
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 129
diff changeset
135 }
1
75b54fd9e73a add new package treevnc
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 }