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
|
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
public class Sommaire extends JFrame implements ActionListener
{
private static final long serialVersionUID = 1L;
// les variables de classe
public JButton bout1, bout2, bout3, bout4, bout5, bout6;
public JPanel pano;
public JLabel menu;
public Font font1, font2;
public JTextField commentaire;
public Sommaire()
{
super();
this.setBounds(1100, 100, 800, 400);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setAlwaysOnTop(true);
this.setResizable(false);
pano = new JPanel();
pano.setLayout(new GridBagLayout());
GridBagConstraints gb =new GridBagConstraints();
gb.weightx=3;
gb.weighty=3;
gb.insets = new Insets(20, 20, 20, 20);
gb.fill = GridBagConstraints.HORIZONTAL;
font1= new Font("TimesRoman",Font.BOLD, 25);
font2 = new Font("TimesRoman",Font.BOLD,20);
commentaire = new JTextField();
commentaire.setSize(80,40);
commentaire.setPreferredSize(commentaire.getSize());
commentaire.setMaximumSize(commentaire.getSize());
menu = new JLabel("MENU GENERAL");
menu.setSize(1100,20);
menu.setPreferredSize(menu.getSize());
menu.setHorizontalAlignment(SwingConstants.CENTER);
menu.setFont(font1);
menu.setForeground(Color.BLUE);
bout1= new JButton("LES SECTIONS");
tailleBouton(bout1);
bout1.addActionListener(this);
bout2 = new JButton("LES BENEVOLES");
tailleBouton(bout2);
bout3 = new JButton("LES ADHERENTS");
tailleBouton(bout3);
bout4 = new JButton("LES ELECTIONS");
tailleBouton(bout4);
bout5 = new JButton("LES INSCRIPTIONS");
tailleBouton(bout5);
bout6 = new JButton("LES STAGES");
tailleBouton(bout6);
// placement des boutons
gb.gridx=2;
gb.gridy=0;
pano.add(menu,gb);
gb.gridx=1;
gb.gridy=1;
pano.add(bout1, gb);
gb.gridx=2;
gb.gridy=1;
pano.add(bout2,gb);
gb.gridx=3;
gb.gridy=1;
pano.add(bout3,gb);
gb.gridx=1;
gb.gridy=2;
pano.add(bout4,gb);
gb.gridx=2;
gb.gridy=2;
pano.add(bout5,gb);
gb.gridx=3;
gb.gridy=2;
pano.add(bout6,gb);
gb.gridx=3;
gb.gridy=0;
pano.add(commentaire,gb);
this.add(pano);
this.setVisible(true);
}
private void tailleBouton(JButton bout)
{
bout.setSize(300,70);
bout.setMinimumSize(bout.getSize());
bout.setPreferredSize(bout.getSize());
bout.setFont(font2);
bout.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource()==bout1)
{
Sections section = new Sections();
this.setAlwaysOnTop(false);
this.dispose();
}
}
} |
Partager