1 /**
2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation, version 3.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14
15 package net.curre.prefcount.event;
16
17 import java.awt.event.ActionEvent;
18 import java.awt.event.ActionListener;
19 import java.awt.event.KeyEvent;
20 import java.awt.event.KeyListener;
21 import javax.swing.*;
22
23 import net.curre.prefcount.PrefCountRegistry;
24
25 /**
26 * Object of this class represents action listener
27 * to get the number of players in the game and opens
28 * a player dialog window.
29 * <p/>
30 * Created date: Jun 2, 2007
31 *
32 * @author Yevgeny Nyden
33 */
34 public class StartAskingQuestionsListener extends AbstractAction
35 implements ActionListener, KeyListener {
36
37 /** Number of players in the game. */
38 int numberOfPlayers;
39
40 /**
41 * Constructor.
42 *
43 * @param numberOfPlayers Number of players in the game.
44 */
45 public StartAskingQuestionsListener(int numberOfPlayers) {
46 this.numberOfPlayers = numberOfPlayers;
47 }
48
49 /** {@inheritDoc} */
50 public void actionPerformed(ActionEvent event) {
51 PrefCountRegistry.getInstance().getMainWindow().startPlayerDialog(numberOfPlayers);
52 }
53
54 /** does nothing */
55 public void keyTyped(KeyEvent keyEvent) {
56 }
57
58 /** does nothing */
59 public void keyPressed(KeyEvent keyEvent) {
60 }
61
62 /** {@inheritDoc} */
63 public void keyReleased(KeyEvent keyEvent) {
64 if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
65 PrefCountRegistry.getInstance().getMainWindow().startPlayerDialog(numberOfPlayers);
66 }
67 }
68
69 }