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
| // ma classe qui est en fait mon panneau principal
public class PanneauAccess extends JPanel {
// constructeur
public PanneauAccess() {
super(new GridLayout(0, 1));
//Les titres des colonnes
String title[] = {"", "Number", "Date", "Status", "Qty", "Price",
"Supplier", ""};
// panneaux de navigation
JPanel panneauSIB = new JPanel(new FlowLayout());
panneauSIB.add(precedentCdeSIB);
panneauSIB.add(suivantCdeSIB);
panneauSIB.add(nbCdeSIB);
panneauSIB.add(new JLabel("/"));
panneauSIB.add(nbTotCdeSIB);
JPanel paneauLSC = new JPanel(new FlowLayout());
paneauLSC.add(precedentCdeLSC);
paneauLSC.add(suivantCdeLSC);
paneauLSC.add(nbCdeLSC);
paneauLSC.add(new JLabel("/"));
paneauLSC.add(nbTotCdeLSC);
JPanel paneauAG = new JPanel(new FlowLayout());
paneauAG.add(precedentCdeAG);
paneauAG.add(suivantCdeAG);
paneauAG.add(nbCdeAG);
paneauAG.add(new JLabel("/"));
paneauAG.add(nbTotCdeAG);
JPanel paneauMims = new JPanel(new FlowLayout());
paneauMims.add(precedentCdeMims);
paneauMims.add(suivantCdeMims);
paneauMims.add(nbMims);
paneauMims.add(new JLabel("/"));
paneauMims.add(nbTotMims);
Object[][] data = { {champsOracleSIB, champsNumberSIB, champsDateSIB,
champsStatutSIB, champsQteCommandeSIBRes, champsPrixSIB, champsSupplierSIB,
panneauSIB },
{champsOracleLSC, champsNumberLSCRes, champsDateLSCRes, champsStatutLSC,
champsQteLSCRes, champsPrixLSCRes, champsSupplierLSCRes,
paneauLSC},
{champsOracleAG, champsNumberAGRes, champsDateAGRes, "",
champsQteAGRes, champsPrixAGRes, champsSupplierAGRes,
paneauAG},
{champsOracleMims, champsNumberMimsRes, champsDateMimsRes, "",
champsQteMimsRes, champsPrixMimsRes, champsSupplierMimsRes,
paneauMims}};
ModeleTableau modele = new ModeleTableau(data, title);
JTable tableau = new JTable(modele);
tableau.setRowHeight(30);
tableau.setGridColor(Color.blue);
tableau.setDefaultRenderer(JLabel.class, new TableComponent());
tableau.setDefaultRenderer(JButton.class, new TableComponent());
tableau.setDefaultRenderer(JPanel.class, new TableComponent());
//On indique que l'entête doit être au nord, donc au-dessus
add(tableau.getTableHeader(), BorderLayout.NORTH);
//Et le corps au centre !
add(tableau, BorderLayout.CENTER);
}
} |