Jump to content



Photo

JTable won't scroll in JScrollPane

Answered Go to the full post java jtable jscrollpane scroll

  • Please log in to reply
3 replies to this topic

#1 thatguyandrew1992

thatguyandrew1992

    Neowinian Senior

  • Tech Issues Solved: 4
  • Joined: 22-January 09

Posted 06 August 2013 - 01:04

I've been having trouble trying to get the table to scroll; it just won't. I've looked some stack answers and tried them, but they aren't working; and I'm not sure if I have something conflicting with those solutions. I just cannot understand what to do from other posts online.

 

I've seen this several times, but I don't know what to do

table.setPreferredScrollableViewportSize(table.getPreferredSize());

my code

tableModel = new TableModel(); //Custom Table Model
table = new JTable();
table.setBorder(null);
table.setFillsViewportHeight(true);
table.setModel(tableModel);

JScrollPane tblScrollPane = new JScrollPane(table);
tblScrollPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
tblScrollPane.setBounds(245, 17, 560, 425);
frmServerAdministration.getContentPane().add(tblScrollPane);


Best Answer thatguyandrew1992 , 06 August 2013 - 02:23

Got it! Im new to table models and didnt call

this.fireTableDataChanged();
this.fireTableStructureChanged();
Go to the full post



#2 OP thatguyandrew1992

thatguyandrew1992

    Neowinian Senior

  • Tech Issues Solved: 4
  • Joined: 22-January 09

Posted 06 August 2013 - 02:23   Best Answer

Got it! Im new to table models and didnt call

this.fireTableDataChanged();
this.fireTableStructureChanged();


#3 Aheer.R.S.

Aheer.R.S.

    I cannot Teach Him, the Boy has no Patience!

  • Tech Issues Solved: 10
  • Joined: 15-October 10

Posted 06 August 2013 - 02:26

HEY that's cheating :p



#4 OP thatguyandrew1992

thatguyandrew1992

    Neowinian Senior

  • Tech Issues Solved: 4
  • Joined: 22-January 09

Posted 06 August 2013 - 13:31

HEY that's cheating :p

What do you mean? haha