Make sure you're adding the JScrollPane
to your JFrame
, not the JTable
. If you originally just had a JFrame
and a JTable
you would have added it like this...
JTable table = new JTable();
JFrame frame = new JFrame();
frame.add(table);
If you're adding the JScrollPane
, you need to change your add()
method to add the JScrollPane
instead of the JTable
, either like this...
JTable table = new JTable();
JFrame frame = new JFrame();
frame.add(new JScrollPane(table));
or like this, if you need to reference the JScrollPane
later in your code...
JTable table = new JTable();
JScrollPane scrollPane = new JScrollPane(table);
JFrame frame = new JFrame();
frame.add(scrollPane);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…