J'essaie de mettre JTable
à l'intérieur JScrollPane
. JScrollPane
est à l'intérieur JPanel
qui est la partie de JTabbedPane
.Ajout de JTable à JScrollPane à l'intérieur de JTabbedPane
Voici le code:
JScrollPane scrollPane = new JScrollPane();
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
JPanel pnlMaxMinAvg1 = new JPanel();
scrollPane.setViewportView(pnlMaxMinAvg1);
tabbedPane.addTab("MaxMinAvg1", null, pnlMaxMinAvg1, null);
pnlMaxMinAvg1.setLayout(new BorderLayout(0,0));
table = new JTable();
table.setModel(new DefaultTableModel(
new Object[][] {{"V_L1_N_RMS_AVG", null}
},
new String[] {
"Variable", "Value"
}
));
table.setBounds(178, 11, 200,300);
scrollPane.add(table);
Quand je lance ce, table
n'est pas affiché. Si je mets:
pnlMaxMinAvg1.add(table);
puis table
est visible.
Pourquoi?