Mercurial > hg > Applications > TreeVNC
view 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 |
line wrap: on
line source
package jp.ac.u_ryukyu.treevnc; import javax.swing.*; import com.glavsoft.viewer.swing.ConnectionParams; import java.awt.*; import java.awt.event.*; public class TreeVncRootSelectionPanel extends JFrame implements ActionListener, ItemListener { /** * */ private static final long serialVersionUID = 1L; private JPanel panel = new JPanel(); private JButton button = new JButton("Connect"); private TextField t1; private TextField t2; private double width = 750; private double height = 500; private JLabel label; private boolean flag; private int counter = 0; // private JCheckBox[] check = new JCheckBox[20]; private Checkbox[] check = new Checkbox[20]; private String port; private CheckboxGroup ch = new CheckboxGroup(); private Container contentPane = getContentPane(); private CreateConnectionParam cp; public TreeVncRootSelectionPanel() { setTitle("TreeVNC Root Address"); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void ipRegister() { setSize(); setText(); setButton(); visible(); } private void setSize() { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); width = (d.getWidth() / 2); height = (d.getHeight() / 2); } public void visible() { Point point = new Point(); point.setLocation(width - 250, height - 80); setLocation(point.getLocation()); pack(); setVisible(true); } public void unVisible() { setVisible(false); } private void setText() { t1 = new TextField("Address", 30); t2 = new TextField(Integer.toString(ConnectionParams.DEFAULT_VNC_ROOT), 5); panel.add(t1); panel.add(t2); //panel.add(button); //button.addActionListener(this); label = new JLabel(); contentPane.add(panel, BorderLayout.CENTER); contentPane.add(label, BorderLayout.SOUTH); } public void checkBox(String str) { if (counter == 0) check[counter] = new Checkbox(str, true, ch); else check[counter] = new Checkbox(str, false, ch); check[counter].addItemListener(this); panel.add(check[counter]); panel.setLayout(new GridLayout(counter + 2, 0)); panel.setLocation((int) width - 250, (int) height - 80); counter++; } public void setButton() { panel.add(button); button.addActionListener(this); contentPane.add(panel, BorderLayout.CENTER); } public String getAddressOption() { while (!(flag)) { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } return t1.getText(); } public String getPortOption() { return t2.getText(); } public String getPort() { return port; } public void actionPerformed(ActionEvent e) { flag = true; for (int t = 0; t < counter; t++) { if (check[t].getState()) { System.out.println(check[t].getLabel()); String str = check[t].getLabel(); String[] temp = str.split(":"); String port = temp[0]; String hostAddress = temp[1]; String rootAddress = temp[2]; cp.setHostName(hostAddress,Integer.parseInt(port),rootAddress); unVisible(); } } } public void itemStateChanged(ItemEvent e) { } public void setCp(CreateConnectionParam cp) { this.cp = cp; } }