1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
   |  
public class Launch extends JFrame {
 
	String adressicon = System.getProperty("user.dir")
    + File.separator + "src" + File.separator + "app" + File.separator
    + "GUI";
	boolean done = false;
	JButton ok = new JButton("OK");
	JCheckBox manager_check = new JCheckBox();
    JCheckBox fireman_check = new JCheckBox();
    JCheckBox policeman_check = new JCheckBox();
 
	public Launch(){
		super();
 
		build();//Window initialization
	}
 
	public class FirstPanel extends JPanel {
		  public FirstPanel(String title) {
		    super(new GridLayout(3, 1));
		    setBorder(BorderFactory.createTitledBorder(title));
 
		    JPanel manager = new JPanel();
		    manager_check.setSelected(true);
		    manager.add(manager_check);
		    JLabel manager_label = new JLabel ("Manager");
		    Icon manager_Icon = new ImageIcon(adressicon + File.separator + "manager.png");
		    manager_label.setIcon(manager_Icon);
		    manager.add(manager_label);
		    manager.setLayout (new FlowLayout(FlowLayout.LEFT));
		    add(manager);
 
		    JPanel fireman = new JPanel();
		    fireman.add(fireman_check);
		    JLabel fireman_label = new JLabel ("Fireman");
		    Icon fireman_Icon = new ImageIcon(adressicon + File.separator + "fireman.png");
		    fireman_label.setIcon(fireman_Icon);
		    fireman.add(fireman_label);
		    fireman.setLayout (new FlowLayout(FlowLayout.LEFT));
		    add(fireman);
 
		    JPanel policeman = new JPanel();
		    policeman.add(policeman_check);
		    JLabel policeman_label = new JLabel ("Policeman");
		    Icon policeman_Icon = new ImageIcon(adressicon + File.separator + "policeman.png");
		    policeman_label.setIcon(policeman_Icon);
		    policeman.add(policeman_label);
		    policeman.setLayout (new FlowLayout(FlowLayout.LEFT));
		    add(policeman);
		  }
	}
 
	public boolean get_Manager () {
		return manager_check.isSelected();
	}
 
	public boolean get_Fireman () {
		return fireman_check.isSelected();
	}
 
	public boolean get_Policeman () {
		return policeman_check.isSelected();
	}
 
	private void build(){
		setTitle("CriSafe v1.0");
		setSize(150,300);
		setLocationRelativeTo(null);
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
		setLayout (new GridLayout(2, 1));
		JPanel panel = new JPanel();
		panel.setLayout (new FlowLayout(FlowLayout.LEFT));
		panel.add(new FirstPanel("Choose your role(s)"));
		add (panel);
		ok.addActionListener ( new ActionListener() {
			 public void actionPerformed(ActionEvent e) {
				 setVisible(false);
				 Main.get_Thread().resume();
			 }
		});
		add (ok);
	}
} | 
Partager