Mercurial > hg > Members > you > BroadCastTreeVNC
view src/treeVnc/TextBoxClient.java @ 6:01cdbc95142f default tip
update build.xml
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 30 Apr 2012 16:04:44 +0900 |
parents | 3b341997141a |
children |
line wrap: on
line source
package treeVnc; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; public class TextBoxClient 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 ArrayList<String> temp = new ArrayList<String>(); private int counter = 0; // private JCheckBox[] check = new JCheckBox[20]; private Checkbox[] check = new Checkbox[20]; private boolean firstFlag = true; private String hostAddress; private String port; private CheckboxGroup ch = new CheckboxGroup(); public TextBoxClient() { setTitle("Informatin Connection Address"); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public void ipRegister() { setSize(); setText(); visible(); } private void setSize() { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); width = (d.getWidth() / 2); height = (d.getHeight() / 2); } 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("5999", 5); panel.add(t1); panel.add(t2); panel.add(button); button.addActionListener(this); label = new JLabel(); Container contentPane = getContentPane(); contentPane.add(panel, BorderLayout.CENTER); contentPane.add(label, BorderLayout.SOUTH); } void checkBox(String str) { // CheckboxGroup ch = new CheckboxGroup(); if (counter == 0) check[counter] = new Checkbox(str, true, ch); else check[counter] = new Checkbox(str, false, ch); // check[counter].setBackground(new Color(0, 153, 255)); 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); // panel.setBackground(Color.blue); button.addActionListener(this); Container contentPane = getContentPane(); contentPane.add(panel, BorderLayout.CENTER); } private void reportWindow() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = getContentPane(); JLabel label = new JLabel( "Not found Proxy. If you use Client-mode you must set-up Proxy"); label.setPreferredSize(new Dimension(580, 50)); label.setFont(new Font("Arial", Font.PLAIN, 20)); pane.add(label); } public String getAddressOption() { while (!(flag)) { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } return t1.getText(); } public String getAddress() { int i = 0; while (!(flag)) { if (i >= 50) { /* reportWindow(); visible(); break; */ return "notFound"; } try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } i++; } return hostAddress; // return t1.getText(); } public String getPortOption() { return t2.getText(); } public String getPort() { return port; // return t2.getText(); } public void actionPerformed(ActionEvent e) { flag = true; for (int t = 0; t < counter; t++) { if (check[t].getState()) { System.out.println(check[t].getLabel()); // if(int t =0) setStatus(check[t].getLabel()); unVisible(); // else // setStatus() } } } private void setStatus(String str) { String[] temp = str.split(":"); if (temp.length == 2) { hostAddress = temp[0]; port = temp[1]; } else { port = temp[0]; System.out.println("port=" + port); hostAddress = temp[3]; } } String splitString(String str) { String[] split = str.split("\\*"); String comper; if (split.length > 4) { split[4] = null; } comper = split[1] + split[3]; if (firstFlag) { temp.add(comper); firstFlag = false; return "port:" + split[0] + ":host:" + split[1] + ":proxy:" + split[3]; } for (int t = 0; t < temp.size(); t++) { if (!(comper.equals(temp.get(t)))) { if (t == temp.size() - 1) { temp.add(comper); return "port:" + split[0] + ":host:" + split[1] + ":proxy:" + split[3]; } } else { break; } } return null; } public void itemStateChanged(ItemEvent e) { } }