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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
| package be.roose.vue;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
public class DesktopContactListe extends JInternalFrame implements ActionListener{
private JPanel monPanel = new JPanel();
private GridBagConstraints gbc = new GridBagConstraints();
private JScrollPane maScrollPaneContact;
private JScrollPane maScrollPanePatient;
private JTable maTableContact;
private JTable maTablePatient;
private JLabel nomTablePatient = new JLabel("Les patients");
private JLabel nomTableContact = new JLabel("Contacts du patient");
private JLabel prenomContactLabel = new JLabel("Prénom");
private JLabel nomContactLabel = new JLabel("Nom");
private JLabel mailContactLabel = new JLabel("E-Mail");
private JLabel telContactLabel = new JLabel("Téléphone");
private JLabel gsmContactLabel = new JLabel("GSM");
private JLabel actifContactLabel = new JLabel("Actif");
private JTextField prenomContactField = new JTextField();
private JTextField nomContactField = new JTextField();
private JTextField mailContactField = new JTextField("");
private JTextField telContactField = new JTextField("");
private JTextField gsmContactField = new JTextField("");
private JComboBox actifContactCombo = new JComboBox();
private JButton quitterBouton = new JButton("Quitter");
private JButton rafraichirBouton = new JButton("Rafraichir");
private JButton sauverBouton = new JButton("Sauver");
private JButton nouveauBouton = new JButton("Nouveau");
private JButton supprimerBouton = new JButton("Supprimer");
public DesktopContactListe(){
this.setTitle("Liste des Contacts");
this.setClosable(true);
this.setResizable(true);
this.setSize(790, 500);
this.setVisible(true);
System.out.println("Contact!");
// Test JTable
Object[][] data = { {"Test1", "28 ans", "1.80 cm"},
{"Test2", "28 ans", "1.80 cm"},
{"Test3", "24 ans", "1.90 cm"},
{"Test4", "32 ans", "1.85 cm"}
};
String title[] = {"Pseudo", "Age", "Taille"};
this.maTableContact = new JTable(data, title);
this.maTablePatient = new JTable (data,title);
maScrollPaneContact = new JScrollPane(maTableContact);
maScrollPanePatient = new JScrollPane(maTablePatient);
// On défnit la combo
actifContactCombo.addItem("Oui");
actifContactCombo.addItem("Non");
// On définit le Grid
monPanel.setLayout(new GridBagLayout());
// On place les Label
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets (10,10,10,10);
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 2;
monPanel.add(nomTablePatient,gbc);
gbc.gridx = 0;
gbc.gridy = 3;
monPanel.add(nomTableContact,gbc);
gbc.gridx = 0;
gbc.gridy = 6;
gbc.gridwidth = 1;
monPanel.add(prenomContactLabel,gbc);
gbc.gridx = 0;
gbc.gridy = 7;
monPanel.add(nomContactLabel,gbc);
gbc.gridx = 0;
gbc.gridy = 8;
monPanel.add(mailContactLabel,gbc);
gbc.gridx = 4;
gbc.gridy = 6;
monPanel.add(telContactLabel,gbc);
gbc.gridx = 4;
gbc.gridy = 7;
monPanel.add(gsmContactLabel,gbc);
gbc.gridx = 4;
gbc.gridy = 8;
monPanel.add(actifContactLabel,gbc);
// On place les TextField
gbc.gridx = 1;
gbc.gridy = 6;
gbc.weightx=50;
gbc.gridwidth = 1;
monPanel.add(prenomContactField,gbc);
gbc.gridx = 1;
gbc.gridy = 7;
monPanel.add(nomContactField,gbc);
gbc.gridx = 1;
gbc.gridy = 8;
monPanel.add(mailContactField,gbc);
gbc.gridx = 5;
gbc.gridy = 6;
gbc.gridwidth = 1;
monPanel.add(telContactField,gbc);
gbc.gridx = 5;
gbc.gridy = 7;
monPanel.add(gsmContactField,gbc);
gbc.gridx = 5;
gbc.gridy = 8;
monPanel.add(actifContactCombo,gbc);
// On place les boutons
gbc.weightx=0;
gbc.weighty=0;
gbc.gridx = 8;
gbc.gridy = 4;
gbc.gridwidth = 1;
monPanel.add(nouveauBouton,gbc);
gbc.gridx = 8;
gbc.gridy = 5;
monPanel.add(supprimerBouton,gbc);
gbc.gridx = 8;
gbc.gridy = 6;
monPanel.add(rafraichirBouton,gbc);
gbc.gridx = 8;
gbc.gridy = 7;
monPanel.add(sauverBouton,gbc);
gbc.gridx = 8;
gbc.gridy = 8;
monPanel.add(quitterBouton,gbc);
// On place la table Contact
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 8;
gbc.weightx=100;
gbc.weighty=100;
monPanel.add(maScrollPaneContact,gbc);
// On place la table Patient
gbc.gridx = 0;
gbc.gridy = 4;
gbc.gridwidth = 8;
gbc.weightx=100;
gbc.weighty=100;
monPanel.add(maScrollPanePatient,gbc);
// On attache monPanel
this.getContentPane().add(monPanel);
// Ecouteur
quitterBouton.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
// On ferme la JInternalFrame
this.dispose();
}
} |
Partager