Mercurial > hg > Members > nobuyasu > tightVNCClient
view src/myVncClient/TextBox.java @ 105:3599045a7312
add broadcast
author | one |
---|---|
date | Tue, 15 Nov 2011 19:53:47 +0900 |
parents | 5241bf573f69 |
children |
line wrap: on
line source
package myVncClient; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; public class TextBox extends JFrame implements ActionListener { private JPanel panel = new JPanel(); private JButton button = new JButton("Connect"); private TextField t1; private TextField t2; private double width; private double height; private JLabel label; private boolean flag; ArrayList<String> temp = new ArrayList<String>(); private int counter=0; private Checkbox[] check = new Checkbox[20]; private boolean firstFlag=true; private String hostAddress; private String port; public void ipRegister() { setSize(); setText(); visible(); } public TextBox() { setTitle("Informatin Connection Address"); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } 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); } private void setText() { t1 = new TextField("dimolto.cr.ie.u-ryukyu.ac.jp", 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(); check[counter] = new Checkbox(str,ch,false); check[counter].setBackground(new Color(0,153,255)); panel.add(check[counter]); panel.setLayout(new GridLayout(counter+2, 0)); counter++; } void setButton(){ panel.add(button); panel.setBackground(Color.blue); button.addActionListener(this); Container contentPane = getContentPane(); contentPane.add(panel, BorderLayout.CENTER); } 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 String getAddress() { while(!(flag)) { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } return hostAddress; //return t1.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()); setStatus(check[t].getLabel()); } } private void setStatus(String str) { String[] temp = str.split(":"); port = temp[1]; System.out.println("port="+port); hostAddress = temp[5]; } }