error while using JTable method

final JTable table =new JTable(data, columnNames);

table.setPreferredScrollableViewportSize(new Dimension(500, 70));

table.setFillsViewportHeight(true);//error here

http://java.sun.com/docs/books/tutorial/uiswing/examples/components/SimpleTableDemoProject/src/components/SimpleTableDemo.java

I was running this example and i get compile time error as

"The method setFillsViewportHeight(boolean) is undefined for the type JTable"

Am i missing anything here?

[665 byte] By [ysrpa] at [2007-11-27 5:19:50]
# 1
Are you using Java 1.6? If not, the method is unavailable.
pbrockway2a at 2007-7-12 10:43:21 > top of Java-index,Desktop,Core GUI APIs...
# 2
> Are you using Java 1.6? If not, the method is> unavailable.Thanks for the reply. No i am using java 1.5.0_06 version. Ok i will upgrade to 1.6. But please tell me what does that method do. I checked in JTable api online and didnt find that method.
ysrpa at 2007-7-12 10:43:21 > top of Java-index,Desktop,Core GUI APIs...
# 3

> But please tell me what does that method do. I checked in JTable api online and

> didnt find that method

You'll need the API documentation for 1.6: http://java.sun.com/javase/6/docs/api/javax/swing/JTable.html

But in this case what it says is "Sets whether or not this table is always made large enough to fill the height of an enclosing viewport. If the preferred height of the table is smaller than the viewport, then the table will be stretched to fill the viewport. In other words, this ensures the table is never smaller than the viewport. The default for this property is false."

I suppose this is handy if your table is inside a scroll pane - you can get rid of those unsightly empty bits.

pbrockway2a at 2007-7-12 10:43:21 > top of Java-index,Desktop,Core GUI APIs...
# 4
Ok i understood now. Thanks for your time.
ysrpa at 2007-7-12 10:43:21 > top of Java-index,Desktop,Core GUI APIs...