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
| package vue;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;
import java.util.TimerTask;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;
import javax.swing.WindowConstants;
import model.*;
import java.util.TimerTask;
public class MontreView extends javax.swing.JFrame{
private static final long serialVersionUID = -57675062963279809L;
Dimension size;
LeTemps h;
LaDate date;
Battery bat;
Montre mon;
Behaviour state;
Timer timer1,timer2,timer3;
PanelAcceuil PA;
PanelSud pS;
private PanelAcceuil2 PA1;
public MontreView( LeTemps g, LaDate d, Battery ba,Montre montre) {
super();
//montre.addObserver(this);
h = g;
bat = ba;
date = d;
mon = montre;
initGUI();
}
private void initGUI() {
try {
this.setTitle("Industrial Project");
this.setIconImage(new ImageIcon("images/crysis3.jpg").getImage());
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setBackground(new java.awt.Color(255,255,255));
size = new Dimension(this.getWidth(), this.getHeight());
this.add(new PanelNord((Observable)mon), BorderLayout.NORTH);
pS = new PanelSud(size,h,date,bat,mon); // instanciation du panel permettant d'afficher l'automate
PA = new PanelAcceuil(size); // instanciation du panel permettant d'afficher l'écran d'acceuil
PA1 = new PanelAcceuil2(size);
timer1 = new Timer(0,new run1(this)); // timer permettant d'afficher l'écran d'acceuil
//timer2 = new Timer(0,new run2(this));
timer3 = new Timer(0,new run3(this)); // timer permettant d'afficher l'automate
//(new acceuil()).start();
//timer2.start();
//timer2.setInitialDelay(100000);
//timer1.start();
//timer1.stop();
//timer3.start();
if(mon.getEvt()==0)
timer1.start();
else{
timer1.stop();
timer3.start();
}
//acceuil t = new acceuil();
//t.start();
pack();
setSize(700, 650);
this.repaint();
} catch (Exception e) {
e.printStackTrace();
}
}
/* class acceuil extends Thread {
public void run(){
while(true){
if(mon.getEvt()==0)
timer1.start();
else{
timer1.stop();
timer2.start();
}
}
}
}*/
public class run1 implements ActionListener{
JFrame p;
public run1(JFrame pan){
p=pan;
}
public void actionPerformed(ActionEvent arg0) {
p.add(PA, BorderLayout.CENTER);
}
}
/* public class run2 implements ActionListener{
JFrame p;
public run2(JFrame pan){
p=pan;
}
public void actionPerformed(ActionEvent arg0) {
p.add(PA1, BorderLayout.CENTER);
}
}*/
public class run3 implements ActionListener{
JFrame p;
public run3(JFrame pan){
p=pan;
}
public void actionPerformed(ActionEvent arg0) {
p.add(pS, BorderLayout.CENTER);
}
}
} |
Partager