Statistics
| Revision:

gvsig-educa / org.gvsig.educa.thematicmap / trunk / org.gvsig.educa.thematicmap / org.gvsig.educa.thematicmap.lib / org.gvsig.educa.thematicmap.lib.prov.locateonthemap / src / main / java / org / gvsig / educa / thematicmap / lib / prov / locateonthemap / DefaultGameWindow.java @ 228

History | View | Annotate | Download (3.81 KB)

1
package org.gvsig.educa.thematicmap.lib.prov.locateonthemap;
2

    
3
import java.awt.BorderLayout;
4
import java.awt.event.ActionEvent;
5
import java.awt.event.ActionListener;
6

    
7
import javax.swing.JButton;
8
import javax.swing.JLabel;
9
import javax.swing.JPanel;
10

    
11
public class DefaultGameWindow extends JPanel {
12

    
13
        private static final long serialVersionUID = 9157246249162455764L;
14

    
15
        private String provinciaASeleccionar = null;
16

    
17
        private JPanel contentPanel;
18
        private JPanel questionPanel;
19

    
20
        private JLabel question;
21
        private JLabel provincia;
22
        private JLabel answer;
23

    
24
        private DefaultGeomSelectSwingManager swingManager;
25

    
26
        private String clickString;
27

    
28
        private JButton botonCerrar;
29
        private JButton botonRestart;
30

    
31
        public DefaultGameWindow() {
32
                // this.swingManager = GeomSelectSwingLocator.getSwingManager();
33
                this.swingManager = new DefaultGeomSelectSwingManager();
34
                initComponents();
35
        }
36

    
37
        private void initComponents() {
38

    
39
                JPanel buttonsPanel = createButtonsPanel();
40

    
41
                this.questionPanel = new JPanel(new BorderLayout());
42
                this.clickString = "Click in one province";
43

    
44
                this.answer = new JLabel(clickString);
45

    
46
                // this.provinciaASeleccionar = GameLocator.getManager()
47
                // .getRandomItem();
48

    
49
                // this.question = getQuestion();
50
                this.question = new JLabel("Selecciona la \n\n siguiente provincia:");
51
                this.provincia = new JLabel(provinciaASeleccionar);
52

    
53
                this.questionPanel.add(this.question, BorderLayout.NORTH);
54
                this.questionPanel.add(this.provincia, BorderLayout.CENTER);
55
                this.questionPanel.add(this.answer, BorderLayout.SOUTH);
56

    
57
                this.contentPanel = new JPanel(new BorderLayout());
58
                // this.contentPanel.setSize(50, 50);
59

    
60
                this.contentPanel.add(this.questionPanel, BorderLayout.NORTH);
61
                this.contentPanel.add(buttonsPanel, BorderLayout.SOUTH);
62

    
63
                this.add(this.contentPanel);
64

    
65
        }
66

    
67
        private void restartPanel() {
68

    
69
                this.questionPanel.remove(this.provincia);
70
                this.questionPanel.remove(this.answer);
71
                // String newRandomProvince = GameLocator.getManager().getRandomItem();
72

    
73
                // while (newRandomProvince.equals(this.provinciaASeleccionar)
74
                // || newRandomProvince.equals("")) {
75
                // newRandomProvince = GameLocator.getManager().getRandomItem();
76

    
77
                // }
78
                // this.provinciaASeleccionar = newRandomProvince;
79

    
80
                this.provincia = new JLabel(provinciaASeleccionar);
81
                this.clickString = "Click in one province";
82
                this.answer = new JLabel(clickString);
83

    
84
                this.questionPanel.add(this.provincia, BorderLayout.CENTER);
85
                this.questionPanel.add(this.answer, BorderLayout.SOUTH);
86

    
87
                this.questionPanel.updateUI();
88
                this.contentPanel.updateUI();
89
                this.updateUI();
90
        }
91

    
92
        public void loadSecondPanel() {
93

    
94
                this.questionPanel.remove(this.answer);
95

    
96
                // if (GameLocator.getManager().isAnswerCorrect()) {
97
                // this.answer = new JLabel("La respuesta es: CORRECTA!!");
98
                // } else {
99
                // this.answer = new JLabel("La respuesta es: INCORRECTA :(");
100
                // }
101

    
102
                this.questionPanel.add(this.answer, BorderLayout.SOUTH);
103

    
104
                this.questionPanel.updateUI();
105
                this.contentPanel.updateUI();
106
                this.updateUI();
107
        }
108

    
109
        private JPanel createButtonsPanel() {
110
                JPanel buttonsPanel = new JPanel(new BorderLayout());
111
                this.botonCerrar = new JButton("Cerrar");
112

    
113
                ActionListener actionClose = new ActionListener() {
114
                        public void actionPerformed(ActionEvent arg0) {
115
                                swingManager.closeWindow();
116
                        }
117
                };
118

    
119
                this.botonRestart = new JButton("Restart");
120

    
121
                ActionListener actioRestart = new ActionListener() {
122
                        public void actionPerformed(ActionEvent arg0) {
123
                                restartPanel();
124
                        }
125
                };
126

    
127
                this.botonCerrar.addActionListener(actionClose);
128
                this.botonRestart.addActionListener(actioRestart);
129
                buttonsPanel.add(this.botonCerrar, BorderLayout.CENTER);
130
                buttonsPanel.add(this.botonRestart, BorderLayout.WEST);
131

    
132
                return buttonsPanel;
133

    
134
        }
135

    
136
        public DefaultGameWindow getGametestWindow() {
137
                return this;
138
        }
139

    
140
        public void setProvinciaASeleccionar(String provincia) {
141
                this.provinciaASeleccionar = provincia;
142
        }
143

    
144
}