Ich versuche JTable
innerhalb JScrollPane
zu setzen. JScrollPane
ist innerhalb JPanel
das ist der Teil von JTabbedPane
. HierJTable zu JScrollPane in JTabbedPane hinzufügen
ist der 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);
Als ich dies ausführen, wird table
nicht angezeigt. Wenn ich ein:
pnlMaxMinAvg1.add(table);
dann ist table
sichtbar.
Warum?