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
| package affichage;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.io.IOException;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import gestion.Intermediaire;
public class FrancePanel extends JComponent {
/**
* ID
*/
private static final long serialVersionUID = 1L;
private Intermediaire service = null;
private JPanel panelFrance = null;
public FrancePanel() throws IOException {
this.service = new Intermediaire();
this.panelFrance = new JPanel(false);
this.setLayout(new GridLayout(1, 1));
// Création des label
JLabel labelDepartement = new JLabel("Nombres de départements : ");
JLabel labelCommune = new JLabel("Nombres de communes : ");
// Création des labels infos
JLabel nombreDepartements = new JLabel(String.valueOf(service
.donneNbDepartement()));
JLabel nombreCommunes = new JLabel(String.valueOf(service
.donneNbCommune()));
// Assignation des labels
nombreDepartements.setLabelFor(nombreDepartements);
nombreCommunes.setLabelFor(nombreCommunes);
// Ajout des labels au panel
JPanel labelPane = new JPanel(new GridLayout(0, 1));
labelPane.add(labelDepartement);
labelPane.add(labelCommune);
// Layout the text fields in a panel.
JPanel fieldPane = new JPanel(new GridLayout(0, 1));
fieldPane.add(nombreDepartements);
fieldPane.add(nombreCommunes);
// Put the panels in this panel, labels on left,
// text fields on right.
setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
add(labelPane, BorderLayout.EAST);
add(fieldPane, BorderLayout.WEST);
}
public JPanel getFrancePanel() throws IOException {
if (panelFrance == null) {
new FrancePanel();
}
return this.panelFrance;
}
} |
Partager