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
| import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Fenetre extends JFrame implements ActionListener {
private JPanel pan;
private JLabel JLB;
private JTextField JTA;
private JLabel JLB1;
private JTextField JTA1;
private JLabel JLB2;
private JTextField JTA2;
private JLabel JLB3;
private JTextField JTA3;
private JLabel JLB4;
private JTextField JTA4;
private JLabel JLB5;
private JTextField JTA5;
private JLabel JLB6;
private JTextField JTA6;
private JCheckBox JCB;
private JCheckBox JCB1;
private JButton JB;
public Fenetre() {
this.setTitle("Logiciel Signature Outlook");
this.setSize(500, 500);
// this.setBackground(Color.yellow);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setContentPane(pan = new JPanel());
pan.setLayout(new BoxLayout(pan,BoxLayout.Y_AXIS));
Container fields = new Container();
GridLayout fieldsLayout = new GridLayout(8,2);
fields.setLayout(fieldsLayout);
fieldsLayout.setVgap(10);
for (Component comp : initFields())
fields.add(comp);
Container JBcontainer = new Container();
JBcontainer.setLayout(new FlowLayout(FlowLayout.CENTER));
JBcontainer.add(JB = new JButton("Valider"));
pan.add(fields);
pan.add(JBcontainer);
this.pack();
this.setLocationRelativeTo(null);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private List<Component> initFields() {
ArrayList<Component> result = new ArrayList<>();
result.add(JLB = new JLabel(" NOM"));
result.add(JTA = new JTextField(" Préciser votre nom"));
JTA.setBackground(Color.lightGray);
result.add(JLB1 = new JLabel(" PRENOM"));
result.add(JTA1 = new JTextField(" Préciser votre prénom"));
result.add(JLB2 = new JLabel(" PÔLE"));
result.add(JTA2 = new JTextField(" Préciser votre Pôle"));
JTA2.setBackground(Color.lightGray);
result.add(JLB3 = new JLabel(" TEL FIXE"));
result.add(JTA3 = new JTextField(" Préciser votre N° de Tél Fixe"));
result.add(JLB4 = new JLabel(" TEL PORTABLE"));
result.add(JTA4 = new JTextField(" Préciser votre N° de Tél Portable"));
JTA4.setBackground(Color.lightGray);
result.add(JLB5 = new JLabel(" FAX"));
result.add(JTA5 = new JTextField(" Préciser votre N° de Fax"));
result.add(JLB6 = new JLabel(" EMAIL"));
result.add(JTA6 = new JTextField(" Préciser votre adresse Email"));
JTA6.setBackground(Color.lightGray);
result.add(JCB = new JCheckBox("Afficher Adresse"));
result.add(JCB1 = new JCheckBox("Afficher Bandeau"));
return result;
}
public void actionPerformed(ActionEvent e) {
// throw new UnsupportedOperationException("Not supported yet."); //To
// change body of generated methods, choose Tools | Templates.
if (e.getSource() == JB) {
System.out.println("Formulaire validé");
} else {
System.out.println("Formulaire non validé");
}
}
public static void main(String[] args) {
new Fenetre();
}
} |
Partager