• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable's setFillsViewportHeight method for Java 1.5?

 
Denise Advincula
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

This Sun's JTable Tutorial is using Java 6. Hence the sample program, TableDemo.java is not compiling for Java 1.5, which is the version I'm currently using now. The error, The method setFillsViewportHeight(boolean) is undefined for the type JTable, points to the setFillsViewportHeight method:



I have used JTables before (in lower versions, Java 1.3) and as far as I can remember, this method can be expressed in other ways. Unfortunately I forgot how. Before I was just copy-pasting working codes from peers (it's bad) so I really wasn't able to grasp the idea of viewports.

Can anybody explain to me how to implement this method in Java 1.5? Thank you very much in advance!
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Denise Saulon:
This Sun's JTable Tutorial is using Java 6. Hence the sample program, TableDemo.java is not compiling for Java 1.5, which is the version I'm currently using now. The error, The method setFillsViewportHeight(boolean) is undefined for the type JTable, points to the setFillsViewportHeight method


That method is new starting with JDK6, so calls to it won't compile with JDK5 and earlier. You should be able to just omit the line and pretty much everything should work. Unless I'm missing something, from the user's point of view it only affects background colors when the table is shorter than the viewport.

Before I was just copy-pasting working codes from peers (it's bad) so I really wasn't able to grasp the idea of viewports.

Can anybody explain to me how to implement this method in Java 1.5?


Viewports are pretty simple, at least as far as idea-grasping goes. Sometimes achieving certain results with them can be tricky. What are you having trouble with?

Well if you really want to implement the effect of this method in JDK5, you can override the getScrollableTracksViewportHeight() method in your JTable. Or if you're just worried about background colors you might want to take a look at this thread.

[edit: correct typos]
[ October 06, 2008: Message edited by: Brian Cole ]
 
Denise Advincula
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for the reply. I got it now!

But I encountered another problem in this thread, I hope you can help me. Thank you in advance!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!