comparison src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncRootSelectionPanel.java @ 434:aad75cd6d9e2

Multicast joins both ipv4 and ipv6 now.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 11 Jun 2016 22:42:58 +0900
parents 3a7d02844cfe
children
comparison
equal deleted inserted replaced
433:ff7fa81f3616 434:aad75cd6d9e2
1 package jp.ac.u_ryukyu.treevnc; 1 package jp.ac.u_ryukyu.treevnc;
2
3 import javax.swing.*;
4 2
5 import com.glavsoft.viewer.swing.ConnectionParams; 3 import com.glavsoft.viewer.swing.ConnectionParams;
6 4
5 import javax.swing.*;
7 import java.awt.*; 6 import java.awt.*;
8 import java.awt.event.*; 7 import java.awt.event.ActionEvent;
9 import java.io.IOException; 8 import java.awt.event.ActionListener;
9 import java.awt.event.ItemEvent;
10 import java.awt.event.ItemListener;
10 11
11 public class TreeVncRootSelectionPanel extends JFrame implements ActionListener, 12 public class TreeVncRootSelectionPanel extends JFrame implements ActionListener,
12 ItemListener { 13 ItemListener {
13 14
14 /** 15 /**
22 private TextField t1; 23 private TextField t1;
23 private TextField t2; 24 private TextField t2;
24 private double width = 750; 25 private double width = 750;
25 private double height = 500; 26 private double height = 500;
26 private JLabel label; 27 private JLabel label;
27 private boolean flag;
28 private int counter = 0; 28 private int counter = 0;
29 // private JCheckBox[] check = new JCheckBox[20]; 29 // private JCheckBox[] check = new JCheckBox[20];
30 private Checkbox[] check = new Checkbox[20]; 30 private Checkbox[] check = new Checkbox[20];
31 private String port; 31 private String port;
32 private CheckboxGroup ch = new CheckboxGroup(); 32 private CheckboxGroup ch = new CheckboxGroup();
85 label = new JLabel(); 85 label = new JLabel();
86 contentPane.add(panel, BorderLayout.CENTER); 86 contentPane.add(panel, BorderLayout.CENTER);
87 contentPane.add(label, BorderLayout.SOUTH); 87 contentPane.add(label, BorderLayout.SOUTH);
88 } 88 }
89 89
90 /**
91 * add tree vnc server selection
92 * @param str
93 */
90 public void checkBox(String str) { 94 public void checkBox(String str) {
91 if (counter == 0) 95 if (counter == 0)
92 check[counter] = new Checkbox(str, true, ch); 96 check[counter] = new Checkbox(str, true, ch);
93 else 97 else
94 check[counter] = new Checkbox(str, false, ch); 98 check[counter] = new Checkbox(str, false, ch);
103 panel.add(button); 107 panel.add(button);
104 button.addActionListener(this); 108 button.addActionListener(this);
105 contentPane.add(panel, BorderLayout.CENTER); 109 contentPane.add(panel, BorderLayout.CENTER);
106 } 110 }
107 111
108 public String getAddressOption() {
109 while (!(flag)) {
110 try {
111 Thread.sleep(500);
112 } catch (InterruptedException e) {
113 e.printStackTrace();
114 }
115 }
116 return t1.getText();
117 }
118 112
119 public String getPortOption() { 113 public String getPortOption() {
120 return t2.getText(); 114 return t2.getText();
121 } 115 }
122 116
124 return port; 118 return port;
125 } 119 }
126 120
127 public void actionPerformed(ActionEvent e) { 121 public void actionPerformed(ActionEvent e) {
128 if (advancedMenu.getSelectedIndex() == 0) { 122 if (advancedMenu.getSelectedIndex() == 0) {
129 flag = true;
130 for (int t = 0; t < counter; t++) { 123 for (int t = 0; t < counter; t++) {
131 int ipv4AddressLength = 3; 124 int ipv4AddressLength = 3;
132 int ipv6AddressLength = 17; 125 int ipv6AddressLength = 17;
133 String port = null; 126 String port = null;
134 String hostAddress = null; 127 String hostAddress = null;
135 String rootAddress = null; 128 String rootAddress = null;
136 if (check[t].getState()) { 129 if (check[t].getState()) {
137 System.out.println(check[t].getLabel()); 130 // System.out.println("Root Seletion Panel get the address : "+e+" "+check[t].getLabel());
138 String str = check[t].getLabel(); 131 String str = check[t].getLabel();
139 String[] temp = str.split(":"); 132 String[] temp = str.split(":");
140 if (temp.length == ipv4AddressLength) { 133 if (temp.length == ipv4AddressLength) {
141 // IPv4 Address 134 // IPv4 Address
142 port = temp[0]; 135 port = temp[0];