changeset 178:ce03da701bcb

create TextBox
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Tue, 25 Oct 2011 01:04:55 +0900
parents ec3842bc0aeb
children 0f0d3193017c
files src/myVncProxy/TextBox.java
diffstat 1 files changed, 81 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/myVncProxy/TextBox.java	Tue Oct 25 01:04:55 2011 +0900
@@ -0,0 +1,81 @@
+package myVncProxy;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+public class TextBox extends JFrame implements ActionListener {
+
+	JPanel panel = new JPanel();
+	JButton button = new JButton("Connect");
+	TextField t1;
+	TextField t2;
+	JPasswordField pw;
+	double width;
+	double height;
+	JLabel label;
+	boolean flag;
+
+	public void ipRegister() {
+		setSize();
+		setText();
+		visible();
+	}
+
+	public TextBox() {
+		setTitle("Informatin Connection Address");
+		setResizable(false);
+		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+	}
+
+	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);
+	}
+
+	void setText() {
+		t1 = new TextField("you.st.ie.u-ryukyu.ac.jp", 30);
+		t2 = new TextField("5900", 5);
+		pw = new JPasswordField("kakiku");
+		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) {
+		flag = true;
+	}
+}
\ No newline at end of file