View Javadoc
1 /***
2 * Copyright (c) 2003 held jointly by the individual authors.
3 *
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; with out even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 *
18 * > http://www.gnu.org/copyleft/lesser.html
19 * > http://www.opensource.org/licenses/lgpl-license.php
20 */
21 /*
22 * Created on Apr 25, 2004
23 *
24 * TODO To change the template for this generated file go to Window -
25 * Preferences - Java - Code Generation - Code and Comments
26 */
27 package net.mlw.gfw.ext.basic.client.component;
28
29 import java.awt.BorderLayout;
30 import java.awt.GridLayout;
31 import java.awt.Image;
32 import java.awt.Toolkit;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
35
36 import javax.swing.ImageIcon;
37 import javax.swing.JButton;
38 import javax.swing.JDialog;
39 import javax.swing.JFrame;
40 import javax.swing.JLabel;
41 import javax.swing.JPanel;
42
43 /***
44 * @author mwilson
45 *
46 * TODO To change the template for this generated type comment go to Window -
47 * Preferences - Java - Code Generation - Code and Comments
48 */
49 public class ChooseTeamDialog extends JDialog
50 {
51 private int team = -1;
52
53 public ChooseTeamDialog(JFrame frame, String[] teamNames, Image image)
54 {
55 super(frame, "Choose:", true);
56 getContentPane().setLayout(new GridLayout(1, 3, 0, 0));
57
58 JPanel team0 = new JPanel(new BorderLayout());
59 team0.add(new JLabel(teamNames[0]), BorderLayout.NORTH);
60 JButton button0 = new JButton("Join");
61 team0.add(button0, BorderLayout.CENTER);
62 button0.addActionListener(new ActionListener()
63 {
64
65 public void actionPerformed(ActionEvent e)
66 {
67 team = 0;
68 setVisible(false);
69 }
70 });
71 getContentPane().add(team0, BorderLayout.WEST);
72
73 getContentPane().add(new JLabel(new ImageIcon(image)), BorderLayout.CENTER);
74
75 JPanel team1 = new JPanel(new BorderLayout());
76 team1.add(new JLabel(teamNames[1]), BorderLayout.NORTH);
77 JButton button1 = new JButton("Join");
78 team1.add(button1, BorderLayout.CENTER);
79 button1.addActionListener(new ActionListener()
80 {
81
82 public void actionPerformed(ActionEvent e)
83 {
84 team = 1;
85 setVisible(false);
86 }
87 });
88 getContentPane().add(team1);
89 pack();
90 }
91
92 public ChooseTeamDialog(JFrame frame, String[] images)
93 {
94 super(frame, "Choose Team", true);
95 getContentPane().setLayout(new GridLayout(1, images.length, 5, 5));
96
97 for (int i = 0, length = images.length; i < length; i++)
98 {
99 final int currentTeam = i;
100 JButton button = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().getImage(ChooseTeamDialog.class.getResource(images[i]))));
101 button.addActionListener(new ActionListener()
102 {
103 public void actionPerformed(ActionEvent e)
104 {
105 team = currentTeam;
106 setVisible(false);
107 }
108 });
109 getContentPane().add(button);
110 }
111 pack();
112 }
113
114 public int getTeam()
115 {
116 return team;
117 }
118 }
This page was automatically generated by Maven