-2

We are using a JTable in a very old huge application to display some information. Till now we were working on Jre 1.7.0_17 or 1.7.0_51. Recently we tried to test our application with an upgraded JRE to 1.7.0_75. We noticed that when the JTable is displayed only one row appears for the first time. However during debug we see data for all rows getting added to table. I tried refresh, revalidate, repaint, fireTableDataChanged etc but still only for the first time only first row appears. If we hide and show the table again all the rows start appearing. Also tested on JREs 1.7.0_80, 1.8.0_31, 1.8.0_45 and 1.8.0_51 and the issue is reproducible. Any hint would be helpful.

(Note : The application was developed on very old java version and has been using old style swing dialogs)

Thank You In Advance!

sumit
  • 1
  • 1
  • Swing GUI objects should be constructed and manipulated _only_ on the [event dispatch thread](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html). – trashgod Sep 10 '15 at 11:17
  • Yes this is taken care! – sumit Sep 10 '15 at 11:28
  • For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson Sep 10 '15 at 12:24
  • I will try to provide one... however most surprising thing to me was something which worked fine started behaving differently with the new JREs. – sumit Sep 10 '15 at 13:55
  • *"..most surprising thing to me was something which worked fine started behaving differently with the new JREs."* There are many things that code can do which will produce a different result on different machines or Java versions. I'm most surprised you are spending time discussing what surprises you, when that time would be better invested in making an MCVE. – Andrew Thompson Sep 10 '15 at 14:18
  • @sumit: I'd check using one of the approaches cited [here](http://stackoverflow.com/q/7787998/230513). – trashgod Sep 10 '15 at 14:41

1 Answers1

0

I haven't seen your code, but a typical problem here is component's size. Most likely, the layout, in which your JTable appears started to calculate component's size differently.

My assumption is easy to verify, buy changing layout to something that does not use preferred size or other similar parameters to calculate component's size. Alternatively, you can set size explicitly just to see what's going on.

That could be done by:

component.setSize(500, 500);

Please note, that it may be more than just 1 container around your JTable. You have to make sure entire stack produces the right size, but start with JTable as it looks like the size is based on some initial empty table's preferred size.

Once you confirm that the problem is where I think it is, you'd need to fix it by changing layout or layout's parameters.

ATrubka
  • 3,982
  • 5
  • 33
  • 52