# HG changeset patch # User one # Date 1321354427 -32400 # Node ID 3599045a7312c31d802f0085fdf946aa6cb9f4d8 # Parent 5241bf573f691a9e729a4786c223bb7c6217f328 add broadcast diff -r 5241bf573f69 -r 3599045a7312 src/myVncClient/MyVncClient.java --- a/src/myVncClient/MyVncClient.java Mon Nov 07 20:29:49 2011 +0900 +++ b/src/myVncClient/MyVncClient.java Tue Nov 15 19:53:47 2011 +0900 @@ -24,10 +24,12 @@ boolean runflag = false; boolean first = true; - EchoClient echoValue; - int echoPort; - String pHost; - TextBox getHost; + private EchoClient echoValue; + private int echoPort; + private String pHost; + private TextBox getHost; + private GetBroadCast getBcast; + private Thread runBcast; // // main() is called when run as a java program from the command line. @@ -44,13 +46,21 @@ mainArgs = argv; inAnApplet = false; inSeparateFrame = true; - getHost = new TextBox(); + getBcast = new GetBroadCast(); + runBcast = new Thread(getBcast); + runBcast.start(); + + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + getBcast.setStopFlag(true); if (mainArgs.length > 0) pHost = mainArgs[0]; else { - getHost.ipRegister(); - pHost = getHost.getAddress(); + pHost = getBcast.text.getAddress(); } @@ -58,8 +68,8 @@ if (mainArgs.length > 1) port = Integer.parseInt(mainArgs[1]); else - - port = 5999; + port = Integer.parseInt(getBcast.text.getPort()); +// port = 5999; init(); start_threads(); diff -r 5241bf573f69 -r 3599045a7312 src/myVncClient/TextBox.java --- a/src/myVncClient/TextBox.java Mon Nov 07 20:29:49 2011 +0900 +++ b/src/myVncClient/TextBox.java Tue Nov 15 19:53:47 2011 +0900 @@ -3,17 +3,25 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.util.ArrayList; public class TextBox extends JFrame implements ActionListener { - JPanel panel = new JPanel(); - JButton button = new JButton("Connect"); - TextField t1; - TextField t2; - double width; - double height; - JLabel label; - boolean flag; + 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 temp = new ArrayList(); + private int counter=0; + private Checkbox[] check = new Checkbox[20]; + private boolean firstFlag=true; + private String hostAddress; + private String port; + public void ipRegister() { setSize(); @@ -21,13 +29,15 @@ visible(); } + public TextBox() { setTitle("Informatin Connection Address"); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } + - void setSize() { + private void setSize() { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); width = (d.getWidth() / 2); height = (d.getHeight() / 2); @@ -41,7 +51,7 @@ setVisible(true); } - void setText() { + private void setText() { t1 = new TextField("dimolto.cr.ie.u-ryukyu.ac.jp", 30); t2 = new TextField("5999", 5); panel.add(t1); @@ -54,6 +64,49 @@ 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