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
| import javax.swing.*;
import java.awt.*;
/**
*
* @author Stephane
*/
public class Main {
public static void main(String[] args) {
new Main();
}
/** Creates a new instance of Main */
public Main() {
JFrame f = new JFrame("Affranchissement");
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setSize(500,500);
JComboBox ListMois = new JComboBox(new String[] {
"Janvier","Février","Mars","Avril",
"Mai","Juin","Juillet","Aout",
"Septembre","Octobre","Novembre","Décembre"
});
ListMois.setLocation(50,50);
f.add(ListMois);
JButton BtnValider = new JButton("Valider");
//BtnValider.setBackground(Color.GRAY);
BtnValider.setBounds(200,200,50,50);
BtnValider.setVisible(true);
f.add(BtnValider);
JButton BtnQuitter = new JButton("Quitter");
//BtnQuitter.setBackground(Color.PINK);
BtnQuitter.setBounds(100,100,50,50);
BtnQuitter.setVisible(true);
f.add(BtnQuitter);
javax.swing.JTextArea sample = new JTextArea();
sample.setText("Tout ça pour ça ! Y'a pas à dire, mais faut en taper du code...");
sample.setEditable(false);
sample.setLineWrap(true);
sample.setBorder(BorderFactory.createEtchedBorder());
f.setLocationRelativeTo(f.getParent());
f.show();
GridBagLayout layout = new GridBagLayout();
getContentPane().setLayout(layout);
GridBagConstraints c1 = new GridBagConstraints();
c1.gridx=0;
c1.gridy=0;
c1.anchor =GridBagConstraints.EAST;
getContentPane().add(ListMois,c1);
GridBagConstraints c2 = new GridBagConstraints();
c2.gridx=0;
c2.gridy=1;
c2.anchor =GridBagConstraints.WEST;
getContentPane().add(BtnValider,c2);
GridBagConstraints c3 = new GridBagConstraints();
c3.gridx=1;
c3.gridy=0;
c3.anchor =GridBagConstraints.SOUTH;
getContentPane().add(BtnQuitter,c3);
GridBagConstraints c4 = new GridBagConstraints();
c4.gridx=1;
c4.gridy=0;
c4.anchor =GridBagConstraints.SOUTH;
getContentPane().add(sample,c4);
}
} |
Partager