Sign in to follow this  
Followers 0

java JTable won't scroll in JScrollPane


4 posts in this topic

Posted

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);

Share this post


Link to post
Share on other sites

Posted

Got it! Im new to table models and didnt call

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

Share this post


Link to post
Share on other sites

Posted

HEY that's cheating :p

Share this post


Link to post
Share on other sites

Posted

HEY that's cheating :p

What do you mean? haha

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.