Mercurial > hg > Members > you > TreeVNC
view src/treeVnc/TextBoxProxy.java @ 22:24112133a0d9
add conf.txt src/treeVnc/ConfFileReader.java
author | Yu Taninari <you@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 20 Jan 2012 16:06:49 +0900 |
parents | 810c53d66376 |
children |
line wrap: on
line source
package treeVnc; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class TextBoxProxy extends JFrame implements ActionListener { /** * */ private static final long serialVersionUID = 1L; private JPanel panel; private JButton button; private JButton button1; private TextField t1; private TextField t2; private JPasswordField pw; private double width; private double height; private JLabel label; private boolean flag; private VncProxyService vps; public void ipRegister() { setSize(); setText(); visible(); } public TextBoxProxy(VncProxyService _vps) { vps = _vps; 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); } private void visible() { Point point = new Point(); point.setLocation(width - 250, height - 80); setLocation(point.getLocation()); pack(); setVisible(true); } private void init(){ frameInit(); // panel = null; // button = null; // label = null; setVisible(false); } public void changeHost() { init(); button1 = new JButton("Change Host"); t1 = new TextField("Address", 30); panel = new JPanel(); panel.add(t1); panel.add(button1); button1.addActionListener(this); label = new JLabel(); Container contentPane = getContentPane(); contentPane.add(panel, BorderLayout.CENTER); contentPane.add(label, BorderLayout.SOUTH); visible(); } private void setText() { panel = new JPanel(); t1 = new TextField("localhost", 30); t2 = new TextField("5900", 5); // pw = new JPasswordField("Password",30); button = new JButton("Connect"); panel.add(t1); panel.add(t2); // panel.add(pw); panel.add(button); button.addActionListener(this); label = new JLabel(); Container contentPane = getContentPane(); contentPane.add(panel, BorderLayout.CENTER); contentPane.add(label, BorderLayout.SOUTH); } public String getAddress() { while(!(flag)) { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } return t1.getText(); } public String getPort() { return t2.getText(); } public String getPassword() { return String.valueOf(pw.getPassword()); } public void actionPerformed(ActionEvent e) { if(e.getSource()==button) { flag = true; setVisible(false); } if(e.getSource()==button1) try { init(); vps.host = getAddress(); vps.changeInit(); } catch (Exception e1) { e1.printStackTrace(); } } }