view src/treeVnc/SelectType.java @ 0:756bfaf731f3

create new repository
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Tue, 21 Feb 2012 04:10:12 +0900
parents
children
line wrap: on
line source

package treeVnc;

import javax.swing.*;

import java.awt.*;
import java.awt.event.*;

public class SelectType extends JFrame implements ActionListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private JPanel panel = new JPanel();
	private JButton button = new JButton("Connect");
	private double width;
	private double height;
	private Checkbox[] check = new Checkbox[2];
	boolean type = false;
	boolean wait = true;
	
	public void selectType() {
		setSize();
		checkBox();
		visible();
	}

	public SelectType() {
		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);
	}
	*/
	
    private void setButton(){
        panel.add(button);
        panel.setBackground(Color.blue);
        button.addActionListener(this);
        Container contentPane = getContentPane();
        contentPane.add(panel, BorderLayout.CENTER);    	
    }
	
	
	private void checkBox() {
        CheckboxGroup ch = new CheckboxGroup();
        check[0] = new Checkbox("Client",ch,false);
        check[0].setBackground(new Color(0,153,255));
        check[1] = new Checkbox("Proxy",ch,false);
        check[1].setBackground(new Color(0,153,255));
        panel.add(check[0]);
        panel.add(check[1]);
        panel.setLayout(new GridLayout(2, 0));
        setButton();
	}
	
	public void actionPerformed(ActionEvent e) {
		if(check[0].getState()){
			System.out.println("Client");
			type = true;
		} else {
			System.out.println("Proxy");
			type = false;
		}
		setVisible(false);
		wait = false;
	}
	
}