comparison src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncRootSelectionPanel.java @ 403:3a7d02844cfe

Enable AdvancedMenu to RootSelectionPanel
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Mon, 19 Oct 2015 17:35:07 +0900
parents 94c520535ef1
children aad75cd6d9e2
comparison
equal deleted inserted replaced
402:73c96a1d4a3a 403:3a7d02844cfe
15 * 15 *
16 */ 16 */
17 private static final long serialVersionUID = 1L; 17 private static final long serialVersionUID = 1L;
18 private final FindRoot findRoot; 18 private final FindRoot findRoot;
19 private JPanel panel = new JPanel(); 19 private JPanel panel = new JPanel();
20 private JButton button = new JButton("Connect"); 20 private JButton button = new JButton("Start");
21 private JButton startRootButton = new JButton("Start as TreeVNC Root"); 21 private JComboBox advancedMenu = new JComboBox();
22 private JButton startDisplayButton = new JButton("Start Display Mode"); 22 private TextField t1;
23 private TextField t1;
24 private TextField t2; 23 private TextField t2;
25 private double width = 750; 24 private double width = 750;
26 private double height = 500; 25 private double height = 500;
27 private JLabel label; 26 private JLabel label;
28 private boolean flag; 27 private boolean flag;
36 35
37 public TreeVncRootSelectionPanel(final FindRoot findRoot) { 36 public TreeVncRootSelectionPanel(final FindRoot findRoot) {
38 this.findRoot = findRoot; 37 this.findRoot = findRoot;
39 setTitle("TreeVNC Root Address"); 38 setTitle("TreeVNC Root Address");
40 setResizable(false); 39 setResizable(false);
41 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 40 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
42 panel.add(startRootButton); 41 setAdvancedMenu();
43 panel.add(startDisplayButton); 42 setButton();
44 startRootButton.addActionListener(new ActionListener() { 43 }
45 @Override 44
46 public void actionPerformed(ActionEvent e) { 45 private void setAdvancedMenu() {
47 cp.setRootMode(); 46 advancedMenu.addItem("Connect to TreeVNC");
48 cp.restart(); 47 advancedMenu.addItem("Start as TreeVNC Root");
49 unVisible(); 48 advancedMenu.addItem("Start Display Mode");
50 } 49 panel.add(advancedMenu);
51 });
52 startDisplayButton.addActionListener(new ActionListener() {
53 @Override
54 public void actionPerformed(ActionEvent e) {
55 cp.setDisplayMode();
56 cp.restart();
57 unVisible();
58 }
59 });
60 contentPane.add(panel, BorderLayout.CENTER); 50 contentPane.add(panel, BorderLayout.CENTER);
61 } 51 }
62 52
63 public void ipRegister() { 53 public void ipRegister() {
64 setSize(); 54 setSize();
65 setText(); 55 setText();
66 setButton(); 56 setButton();
67 visible(); 57 visible();
68 } 58 }
133 public String getPort() { 123 public String getPort() {
134 return port; 124 return port;
135 } 125 }
136 126
137 public void actionPerformed(ActionEvent e) { 127 public void actionPerformed(ActionEvent e) {
138 flag = true; 128 if (advancedMenu.getSelectedIndex() == 0) {
139 for (int t = 0; t < counter; t++) { 129 flag = true;
140 int ipv4AddressLength = 3; 130 for (int t = 0; t < counter; t++) {
141 int ipv6AddressLength = 17; 131 int ipv4AddressLength = 3;
142 String port = null; 132 int ipv6AddressLength = 17;
143 String hostAddress = null; 133 String port = null;
144 String rootAddress = null; 134 String hostAddress = null;
145 if (check[t].getState()) { 135 String rootAddress = null;
146 System.out.println(check[t].getLabel()); 136 if (check[t].getState()) {
147 String str = check[t].getLabel(); 137 System.out.println(check[t].getLabel());
148 String[] temp = str.split(":"); 138 String str = check[t].getLabel();
149 if (temp.length == ipv4AddressLength) { 139 String[] temp = str.split(":");
150 // IPv4 Address 140 if (temp.length == ipv4AddressLength) {
151 port = temp[0]; 141 // IPv4 Address
152 hostAddress = temp[1]; 142 port = temp[0];
153 rootAddress = temp[2]; 143 hostAddress = temp[1];
154 } else if (temp.length == ipv6AddressLength) { 144 rootAddress = temp[2];
155 // IPv6 Address 145 } else if (temp.length == ipv6AddressLength) {
156 port = temp[0]; 146 // IPv6 Address
157 hostAddress = temp[1] + ":" + temp[2] + ":" + temp[3] + ":" + temp[4] + ":" + temp[5] + ":" + temp[6] + ":" + temp[7] + ":" + temp[8]; 147 port = temp[0];
158 rootAddress = temp[9] + ":" + temp[10] + ":" + temp[11] + ":" + temp[12] + ":" + temp[13] + ":" + temp[14] + ":" + temp[15] + ":" + temp[16]; 148 hostAddress = temp[1] + ":" + temp[2] + ":" + temp[3] + ":" + temp[4] + ":" + temp[5] + ":" + temp[6] + ":" + temp[7] + ":" + temp[8];
159 } 149 rootAddress = temp[9] + ":" + temp[10] + ":" + temp[11] + ":" + temp[12] + ":" + temp[13] + ":" + temp[14] + ":" + temp[15] + ":" + temp[16];
160 cp.setHostName(hostAddress,Integer.parseInt(port),rootAddress); 150 }
161 unVisible(); 151 cp.setHostName(hostAddress, Integer.parseInt(port), rootAddress);
152 unVisible();
153 }
162 } 154 }
155 } else if (advancedMenu.getSelectedIndex() == 1) {
156 // selected "Start as TreeVNC Root"
157 cp.setRootMode();
158 cp.restart();
159 unVisible();
160 } else if (advancedMenu.getSelectedIndex() == 2) {
161 // selected "Start Display Mode"
162 cp.setDisplayMode();
163 cp.restart();
164 unVisible();
163 } 165 }
164 } 166 }
165 167
166 168
167 public void itemStateChanged(ItemEvent e) { 169 public void itemStateChanged(ItemEvent e) {