diff src/main/java/jp/ac/u_ryukyu/treevnc/server/TextBoxProxy.java @ 12:12c3a73be47f

rename package
author one
date Tue, 21 Aug 2012 14:24:38 +0900
parents src/main/java/ac/ryukyu/treevnc/server/TextBoxProxy.java@57ae9fbb1245
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/TextBoxProxy.java	Tue Aug 21 14:24:38 2012 +0900
@@ -0,0 +1,126 @@
+package jp.ac.u_ryukyu.treevnc.server;
+
+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();
+			}
+	}
+}
\ No newline at end of file