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
|
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FenetrePrincipale extends JFrame{
//...
//...
//plein d'attributs, dont :
SimPed sim;
public FenetrePrincipale(){
//Nouvelle fenetre
super("Simulateur 2.0");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.show();
}
//La methode suivante est appellé par mon Main:
public void init() {
//Nouvelle simulation
this.sim = new SimPed(couloir , TICKS , simulation , scenario , TRAF);
go();
}
public void go() {
// Pleins d'initialisation, de JPanel, JButton , JLabel etc etc ..
//en particulier menuBouton, menuTemps, menuPerso...
// Puis mise en place des composants:
this.getContentPane().removeAll();
this.getContentPane().add(sim, BorderLayout.CENTER);
this.getContentPane().add(menuBouton , BorderLayout.WEST);
this.getContentPane().add(menuTemps , BorderLayout.SOUTH);
this.getContentPane().add(menuPerso, BorderLayout.EAST);
this.pack();
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
this.show();
}
} |
Partager