This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes JTable's setFillsViewportHeight method for Java 1.5? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JTable Watch "JTable New topic
Author

JTable's setFillsViewportHeight method for Java 1.5?

Denise Advincula
Ranch Hand

Joined: Jan 01, 2007
Posts: 153
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!


SCJP/OCPJP 6 | SCWCD/OCPJWCD 5 | OCPJBCD in progress
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 852
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 ]

bitguru blog
Denise Advincula
Ranch Hand

Joined: Jan 01, 2007
Posts: 153
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!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: JTable's setFillsViewportHeight method for Java 1.5?
 
Similar Threads
Jtable
JTable
updating jTable
Passing Database query results through a method to a JTable
JTable(!!!)