-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
595 lines (515 loc) · 30.2 KB
/
Copy pathMain.java
File metadata and controls
595 lines (515 loc) · 30.2 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
package mathmaster;
import mathmaster.util.Alumno;
import mathmaster.util.NavegadorFrames;
import java.awt.*;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.LocalDateTime;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.Timer;
import mathmaster.enumerados.InterfazMakey;
import mathmaster.enumerados.Lenguaje;
import mathmaster.util.Configurador;
import mathmaster.util.Constantes;
import java.util.Properties;
import java.util.List;
/**
*
* @author Ruben
*/
public class Main extends javax.swing.JFrame {
private Configurador configuracion;
int xsize,ysize;
Dimension pantallaTamano;
public Main() {
configuracion = Configurador.getInstance();
this.setContentPane(new BackgroundPanel());
this.setIconImage (new ImageIcon(getClass().getResource("/mathmaster/icono2.png")).getImage());
initComponents();
this.botonES.setToolTipText("Español");
this.botonUK.setToolTipText("Inglés");
this.botonfruta.setToolTipText("Jugamos con alimentos");
this.botonplasti.setToolTipText("Jugamos con plastilina");
this.setTitle("PrimaryCode");
if (configuracion.isIngles()){
this.interaccion.setText("Select Interaction");
this.idioma.setText("Select Language");
botonEmpezar.setIcon(new ImageIcon(getClass().getResource("/mathmaster/botonempezarUK.png")));
botonEmpezar.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonempezarpressUK.png")));
botonEmpezar.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonempezarselecUK.png")));
botonSalir.setIcon(new ImageIcon(getClass().getResource("/mathmaster/botonsalirUK.png")));
botonSalir.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonsalirpressUK.png")));
botonSalir.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonsalirselecUK.png")));
titulo.setIcon(new ImageIcon(getClass().getResource("/mathmaster/tituloUK.png")));
botonInvitado.setIcon(new ImageIcon(getClass().getResource("/mathmaster/botonProbarUK.png")));
botonInvitado.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonProbarpressUK.png")));
botonInvitado.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonProbarselecUK.png")));
}
Toolkit tk = Toolkit.getDefaultToolkit();
pantallaTamano = Toolkit.getDefaultToolkit().getScreenSize();
xsize = ((int) tk.getScreenSize().getWidth());
ysize = ((int) tk.getScreenSize().getHeight());
this.setSize(1024, 720);
this.setLocationRelativeTo(null);
seleccionarIconosInterfazMakey(this.configuracion.getInterfazMakey());
seleccionarIconosLenguaje(this.configuracion.getLang());
// NewHibernateUtil hibernate = new NewHibernateUtil();
//
// List<mathmaster.util.Profesor> profesoresBd;
// profesoresBd = hibernate.obtenerProfesores();
// String listaProfesores = profesoresBd.toString();
//
// contenidoProfesores.setText(listaProfesores);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
botonEmpezar = new javax.swing.JButton();
botonSalir = new javax.swing.JButton();
botonUK = new javax.swing.JButton();
botonES = new javax.swing.JButton();
botonfruta = new javax.swing.JButton();
botonplasti = new javax.swing.JButton();
interaccion = new javax.swing.JLabel();
idioma = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
botonProfesor = new javax.swing.JButton();
textoPortalProfesor = new javax.swing.JLabel();
botonInvitado = new javax.swing.JButton();
titulo = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(800, 600));
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
getContentPane().setLayout(null);
botonEmpezar.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
botonEmpezar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/botonempezar.png"))); // NOI18N
botonEmpezar.setBorder(null);
botonEmpezar.setBorderPainted(false);
botonEmpezar.setContentAreaFilled(false);
botonEmpezar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
botonEmpezar.setMaximumSize(new java.awt.Dimension(150, 100));
botonEmpezar.setMinimumSize(new java.awt.Dimension(150, 100));
botonEmpezar.setPreferredSize(new java.awt.Dimension(150, 100));
botonEmpezar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/botonempezarpress.png"))); // NOI18N
botonEmpezar.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/botonempezarselec.png"))); // NOI18N
botonEmpezar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
botonEmpezarActionPerformed(evt);
}
});
getContentPane().add(botonEmpezar);
botonEmpezar.setBounds(360, 450, 160, 90);
botonSalir.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
botonSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/botonsalir.png"))); // NOI18N
botonSalir.setBorderPainted(false);
botonSalir.setContentAreaFilled(false);
botonSalir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
botonSalir.setPreferredSize(new java.awt.Dimension(150, 100));
botonSalir.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/botonsalirpress.png"))); // NOI18N
botonSalir.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/botonsalirselec.png"))); // NOI18N
botonSalir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
botonSalirActionPerformed(evt);
}
});
getContentPane().add(botonSalir);
botonSalir.setBounds(560, 450, 160, 90);
botonUK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/ukflag.png"))); // NOI18N
botonUK.setToolTipText("");
botonUK.setBorder(null);
botonUK.setContentAreaFilled(false);
botonUK.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
botonUK.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/ukflagpress.png"))); // NOI18N
botonUK.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/ukflagselec.png"))); // NOI18N
botonUK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
botonUKActionPerformed(evt);
}
});
getContentPane().add(botonUK);
botonUK.setBounds(890, 70, 46, 30);
botonES.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/esflag.png"))); // NOI18N
botonES.setToolTipText("");
botonES.setBorder(null);
botonES.setContentAreaFilled(false);
botonES.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
botonES.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/esflagpress.png"))); // NOI18N
botonES.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/esflagselec.png"))); // NOI18N
botonES.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
botonESActionPerformed(evt);
}
});
getContentPane().add(botonES);
botonES.setBounds(810, 70, 46, 30);
botonfruta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/fruta.png"))); // NOI18N
botonfruta.setToolTipText("");
botonfruta.setContentAreaFilled(false);
botonfruta.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/frutapress.png"))); // NOI18N
botonfruta.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/frutaselec.png"))); // NOI18N
botonfruta.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
botonfrutaActionPerformed(evt);
}
});
getContentPane().add(botonfruta);
botonfruta.setBounds(800, 160, 67, 50);
botonplasti.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/plasti.png"))); // NOI18N
botonplasti.setToolTipText("");
botonplasti.setContentAreaFilled(false);
botonplasti.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/plastipress.png"))); // NOI18N
botonplasti.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/plastiselec.png"))); // NOI18N
botonplasti.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
botonplastiActionPerformed(evt);
}
});
getContentPane().add(botonplasti);
botonplasti.setBounds(880, 160, 60, 60);
interaccion.setFont(new java.awt.Font("Comic Sans MS", 1, 12)); // NOI18N
interaccion.setText("Selecciona Interacción");
getContentPane().add(interaccion);
interaccion.setBounds(810, 140, 170, 20);
idioma.setFont(new java.awt.Font("Comic Sans MS", 1, 12)); // NOI18N
idioma.setText("Selecciona Idioma");
getContentPane().add(idioma);
idioma.setBounds(820, 40, 170, 20);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/titulo_1.png"))); // NOI18N
getContentPane().add(jLabel1);
jLabel1.setBounds(220, 60, 620, 120);
botonProfesor.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
botonProfesor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/profesor.png"))); // NOI18N
botonProfesor.setBorderPainted(false);
botonProfesor.setContentAreaFilled(false);
botonProfesor.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
botonProfesor.setPreferredSize(new java.awt.Dimension(155, 105));
botonProfesor.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/profesorpres.png"))); // NOI18N
botonProfesor.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/profesorselec.png"))); // NOI18N
botonProfesor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
botonProfesorActionPerformed(evt);
}
});
getContentPane().add(botonProfesor);
botonProfesor.setBounds(820, 560, 160, 100);
textoPortalProfesor.setFont(new java.awt.Font("Comic Sans MS", 1, 12)); // NOI18N
textoPortalProfesor.setText("Acceder a portal profesor");
textoPortalProfesor.setToolTipText("");
getContentPane().add(textoPortalProfesor);
textoPortalProfesor.setBounds(820, 670, 160, 14);
botonInvitado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/botonProbar.png"))); // NOI18N
botonInvitado.setBorder(null);
botonInvitado.setBorderPainted(false);
botonInvitado.setContentAreaFilled(false);
botonInvitado.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/botonProbarpress.png"))); // NOI18N
botonInvitado.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/botonProbarselec.png"))); // NOI18N
botonInvitado.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
botonInvitadoActionPerformed(evt);
}
});
getContentPane().add(botonInvitado);
botonInvitado.setBounds(460, 560, 160, 90);
titulo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mathmaster/titulo.png"))); // NOI18N
titulo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
titulo.setMaximumSize(new java.awt.Dimension(2147483647, 2147483647));
getContentPane().add(titulo);
titulo.setBounds(260, 130, 540, 620);
pack();
}// </editor-fold>//GEN-END:initComponents
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
int choice = 0;
if (configuracion.isIngles()){
choice = JOptionPane.showOptionDialog(null, "¿Do you want to quit?", "Quit", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
}else if (configuracion.isEspanol()){
choice = JOptionPane.showOptionDialog(null, "¿Quieres salir?", "Salir", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
}
if (choice == JOptionPane.YES_OPTION){
//baseDatos.escribirFichero();
System.exit(0);
}else
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}//GEN-LAST:event_formWindowClosing
private void elegirAlumno(){
JTextField campoNombre = new JTextField(10);
JTextField campoApellido = new JTextField(10);
JPanel pPanel = new JPanel();
if(configuracion.isIngles())
pPanel.add(new JLabel("Name: "));
else
pPanel.add(new JLabel("Nombre: "));
pPanel.add(campoNombre);
if(configuracion.isIngles())
pPanel.add(new JLabel("Last Name: "));
else
pPanel.add(new JLabel("Apellido: "));
pPanel.add(campoApellido);
int result=0;
if(configuracion.isIngles())
result = JOptionPane.showConfirmDialog(this,pPanel,"Input your Name and Last Name",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);
else
result = JOptionPane.showConfirmDialog(this,pPanel,"Escribe tu Nombre y Apellido",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.OK_OPTION){
String nombre = campoNombre.getText();
String apellido = campoApellido.getText();
if((nombre.equalsIgnoreCase("")) || (apellido.equalsIgnoreCase(""))){
if(configuracion.isIngles())
JOptionPane.showMessageDialog(null,"Input a valid name and last name","Error",JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(null,"Escribe un Nombre y Apellido valido","Error",JOptionPane.INFORMATION_MESSAGE);
}else{
if (configuracion.getBaseDatos().buscarAlumno(nombre, apellido)){
if(configuracion.isIngles())
JOptionPane.showMessageDialog(null,"User found","Correct",JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(null,"Usuario encontrado","Correcto",JOptionPane.INFORMATION_MESSAGE);
int progreso=configuracion.getBaseDatos().devolverProgreso(nombre, apellido);
int contador=configuracion.getBaseDatos().devolverContador(nombre, apellido);
int puntos = configuracion.getBaseDatos().devolverPuntos(nombre, apellido);
Alumno alumnoElegido = new Alumno(nombre,apellido,progreso,contador,puntos);
configuracion.setAlumnoActual(alumnoElegido);
NavegadorFrames.navegarA(NavegadorFrames.ELEGIR_MODO);
this.setVisible(false);
}else{
Alumno alumnoElegido = new Alumno(nombre,apellido,0,configuracion.getBaseDatos().getContador(),0);
configuracion.getBaseDatos().añadirAlumno(alumnoElegido);
configuracion.setAlumnoActual(alumnoElegido);
NavegadorFrames.navegarA(NavegadorFrames.ELEGIR_MODO);
this.setVisible(false);
}
}
}
configuracion.getBaseDatos().leerFichero();
configuracion.getBaseDatos().escribirFichero();
}
private void botonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonSalirActionPerformed
int choice = JOptionPane.showOptionDialog(null, "¿Quieres salir?", "Salir", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
if (choice == JOptionPane.YES_OPTION){
//baseDatos.escribirFichero();
System.exit(0);
}else
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}//GEN-LAST:event_botonSalirActionPerformed
private void seleccionarIconosLenguaje(Lenguaje elegido){
this.configuracion.setLang(elegido);
if(elegido.equals(Lenguaje.INGLES)){
botonES.setIcon(new ImageIcon(getClass().getResource("/mathmaster/esflagbn.png")));
botonUK.setIcon(new ImageIcon(getClass().getResource("/mathmaster/ukflag.png")));
}else{
botonES.setIcon(new ImageIcon(getClass().getResource("/mathmaster/esflag.png")));
botonUK.setIcon(new ImageIcon(getClass().getResource("/mathmaster/ukflagbn.png")));
}
}
private void botonUKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonUKActionPerformed
seleccionarIconosLenguaje(Lenguaje.INGLES);
this.interaccion.setText("Select Interaction");
this.idioma.setText("Select Language");
botonES.setToolTipText("Spanish");
botonUK.setToolTipText("English");
botonfruta.setToolTipText("We play with food");
botonplasti.setToolTipText("We play with clay");
botonEmpezar.setIcon(new ImageIcon(getClass().getResource("/mathmaster/botonempezarUK.png")));
botonEmpezar.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonempezarpressUK.png")));
botonEmpezar.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonempezarselecUK.png")));
botonSalir.setIcon(new ImageIcon(getClass().getResource("/mathmaster/botonsalirUK.png")));
botonSalir.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonsalirpressUK.png")));
botonSalir.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonsalirselecUK.png")));
titulo.setIcon(new ImageIcon(getClass().getResource("/mathmaster/tituloUK.png")));
botonProfesor.setIcon(new ImageIcon(getClass().getResource("/mathmaster/profesorUK.png")));
botonProfesor.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/profesorpressUK.png")));
botonProfesor.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/profesorselecUK.png")));
botonInvitado.setIcon(new ImageIcon(getClass().getResource("/mathmaster/botonProbarUK.png")));
botonInvitado.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonProbarpressUK.png")));
botonInvitado.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonProbarselecUK.png")));
this.textoPortalProfesor.setText("Access to teachers portal");
this.configuracion.setLang(Lenguaje.INGLES);
}//GEN-LAST:event_botonUKActionPerformed
private void botonESActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonESActionPerformed
seleccionarIconosLenguaje(Lenguaje.ESPANOL);
this.interaccion.setText("Selecciona Interacción");
this.idioma.setText("Selecciona Idioma");
botonES.setToolTipText("Español");
botonUK.setToolTipText("Inglés");
botonfruta.setToolTipText("Jugamos con alimentos");
botonplasti.setToolTipText("Jugamos con plastilina");
botonEmpezar.setIcon(new ImageIcon(getClass().getResource("/mathmaster/botonempezar.png")));
botonEmpezar.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonempezarpress.png")));
botonEmpezar.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonempezarselec.png")));
botonSalir.setIcon(new ImageIcon(getClass().getResource("/mathmaster/botonsalir.png")));
botonSalir.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonsalirpress.png")));
botonSalir.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonsalirselec.png")));
titulo.setIcon(new ImageIcon(getClass().getResource("/mathmaster/titulo.png")));
botonProfesor.setIcon(new ImageIcon(getClass().getResource("/mathmaster/profesor.png")));
botonProfesor.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/profesorpres.png")));
botonProfesor.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/profesorselec.png")));
botonInvitado.setIcon(new ImageIcon(getClass().getResource("/mathmaster/botonProbar.png")));
botonInvitado.setPressedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonProbarpress.png")));
botonInvitado.setSelectedIcon(new ImageIcon(getClass().getResource("/mathmaster/botonProbarselec.png")));
this.textoPortalProfesor.setText("Acceso a portal profesor");
this.configuracion.setLang(Lenguaje.ESPANOL);
}//GEN-LAST:event_botonESActionPerformed
private void seleccionarIconosInterfazMakey(InterfazMakey seleccionado){
this.configuracion.setInterfazMakey(seleccionado);
if(seleccionado.equals(InterfazMakey.FRUTAS)){
botonfruta.setIcon(new ImageIcon(getClass().getResource("/imagenes/fruta.png")));
botonplasti.setIcon(new ImageIcon(getClass().getResource("/imagenes/plastibn.png")));
}else{
botonfruta.setIcon(new ImageIcon(getClass().getResource("/imagenes/frutabn.png")));
botonplasti.setIcon(new ImageIcon(getClass().getResource("/imagenes/plasti.png")));
}
}
private void botonfrutaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonfrutaActionPerformed
seleccionarIconosInterfazMakey(InterfazMakey.FRUTAS);
}//GEN-LAST:event_botonfrutaActionPerformed
private void botonplastiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonplastiActionPerformed
seleccionarIconosInterfazMakey(InterfazMakey.PLASTILINA);
}//GEN-LAST:event_botonplastiActionPerformed
private void botonProfesorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonProfesorActionPerformed
JPasswordField campoContrasena = new JPasswordField(10);
JPanel pPanel = new JPanel();
if(this.configuracion.isIngles())
pPanel.add(new JLabel("Please enter the password: "));
else if (this.configuracion.isEspanol())
pPanel.add(new JLabel("Por favor escriba la contraseña: "));
pPanel.add(campoContrasena);
int result=0;
if(this.configuracion.isIngles())
result = JOptionPane.showConfirmDialog(this,pPanel,"Input the password",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);
else if(this.configuracion.isEspanol())
result = JOptionPane.showConfirmDialog(this,pPanel,"Escribe la contraseña",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.OK_OPTION){
String contrasena = String.valueOf(campoContrasena.getPassword());
if(contrasena.equalsIgnoreCase(Constantes.PASSWORD)){
NavegadorFrames.navegarA(NavegadorFrames.PROFESOR);
this.setVisible(false);
}else {
if(this.configuracion.isIngles())
JOptionPane.showMessageDialog(pPanel, "Wrong password");
else if(this.configuracion.isEspanol())
JOptionPane.showMessageDialog(pPanel, "Contraseña Incorrecta");
}
}
}//GEN-LAST:event_botonProfesorActionPerformed
private void botonEmpezarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonEmpezarActionPerformed
if ((!configuracion.isFruta())&&(!configuracion.isPlasti())){
if (configuracion.isIngles())
JOptionPane.showMessageDialog(null, "Select an object before start");
else
JOptionPane.showMessageDialog(null, "Elige un objeto de arriba antes de empezar");
}else{
elegirAlumno();
}
}//GEN-LAST:event_botonEmpezarActionPerformed
private void botonInvitadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonInvitadoActionPerformed
Alumno invitado = new Alumno("Invitado", "", 0, 0, 0);
Configurador.getInstance().setAlumnoActual(invitado);
NavegadorFrames.navegarA(NavegadorFrames.ELEGIR_MODO);
this.setVisible(false);
}//GEN-LAST:event_botonInvitadoActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
// NewHibernateUtil hibernate = new NewHibernateUtil();
//
// mathmaster.util.Profesor profeDiego = new mathmaster.util.Profesor();
// profeDiego.setNombre("Diegoch"+LocalDateTime.now().toString());
// profeDiego.setEmail("diego.digionantonio@gmail.com");
// profeDiego.setPin("6875u");
// profeDiego.setFechaAlta(LocalDateTime.now());
//
//// hibernate.insertarProfesor(profeDiego);
//
// List<mathmaster.util.Profesor> profesoresBd;
// profesoresBd = hibernate.obtenerProfesores();
// System.out.println("Los profes son: " + profesoresBd);
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Main().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton botonES;
private javax.swing.JButton botonEmpezar;
private javax.swing.JButton botonInvitado;
private javax.swing.JButton botonProfesor;
private javax.swing.JButton botonSalir;
private javax.swing.JButton botonUK;
private javax.swing.JButton botonfruta;
private javax.swing.JButton botonplasti;
private javax.swing.JLabel idioma;
private javax.swing.JLabel interaccion;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel textoPortalProfesor;
private javax.swing.JLabel titulo;
// End of variables declaration//GEN-END:variables
}
class BackgroundPanel extends JPanel {
private Image image;
public BackgroundPanel() {
MediaTracker tracker=new MediaTracker(this);
image=Toolkit.getDefaultToolkit().getImage(getClass().getResource("/mathmaster/fondo3.png"));
tracker.addImage(this.image, 0);
try {
tracker.waitForID(0);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null)
g.drawImage(image, 0,0,this.getWidth(),this.getHeight(),this);
}
}