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
| public class NiveauGrisVueEnsemble implements Observer
{
private NiveauGrisController ngc;
private NiveauGrisModel ngm;
private JFrame ngf;
private JScrollPane sp;
private JPanel container ;
private JButton addNiveauGris, deleteNiveauGris, calculerNiveauGris ;
private ArrayList<NiveauGrisPanel> panels ;
public NiveauGrisVueEnsemble(NiveauGrisController ngc, NiveauGrisModel ngm)
{
this.ngc = ngc ;
this.ngm = ngm ;
ngm.addObserver(this);
panels = new ArrayList<NiveauGrisPanel>() ;
ngf = new JFrame("Calcul du niveau de gris") ;
ngf.setSize(500,200) ;
ngf.setLocationRelativeTo(null) ;
ngf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ;
container = new JPanel() ;
addNiveauGris = new JButton("+") ;
addNiveauGris.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
panels.add(new NiveauGrisPanel()) ;
container.removeAll() ;
ngf.removeAll() ;
for ( NiveauGrisPanel ngp : panels)
{
container.add(ngp) ;
}
container.add(deleteNiveauGris) ;
container.add(addNiveauGris) ;
container.add(calculerNiveauGris) ;
container.validate() ;
container.repaint() ;
sp.add(container) ;
sp.revalidate() ;
sp.repaint() ;
ngf.getContentPane().add(sp) ;
ngf.getContentPane().validate() ;
ngf.getContentPane().repaint() ;
}
}) ;
addNiveauGris.setToolTipText("Ajouter un niveau de gris") ;
deleteNiveauGris = new JButton("-") ;
deleteNiveauGris.setToolTipText("Enlever un niveau de gris") ;
calculerNiveauGris = new JButton("Calculer les niveaux de gris") ;
container.setLayout(new FlowLayout(FlowLayout.CENTER)) ;
container.add(deleteNiveauGris) ;
container.add(addNiveauGris) ;
container.add(calculerNiveauGris) ;
sp = new JScrollPane(container) ;
ngf.getContentPane().add(sp) ;
ngf.setVisible(true) ;
}
public void update(Observable o, Object arg)
{
}
} |
Partager