For Programmers: Free Programming Magazines  


Home > Archive > Java Beans > February 2005 > Purpose of "getViewport()" in Swing ??









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Purpose of "getViewport()" in Swing ??
Ulf Meinhardt

2005-02-12, 3:57 pm

What is the difference between

myScrollPane.add(myJTable);

and

myScrollPane.getViewport().add(myJTable);

?

Ulf

Frank Liu

2005-02-12, 8:57 pm

As I understand it when adding a JTable to the scrollpane, the table or
maybe the scrollpane will check to see if the container is a scrollpane. If
it is it will add its JTableHeader to the scrollpane's getHeaderViewport. So
if you add table to the scrollpane using the 2nd method the Table header
might not show. This is also how people make row header like table header.
They create another JTable and put it in the scrollpane's
getRowHeaderViewport.

Frank

"Ulf Meinhardt" <ulf2m@email.com> wrote in message
news:cukui8$12b$01$1@news.t-online.com...
> What is the difference between
>
> myScrollPane.add(myJTable);
>
> and
>
> myScrollPane.getViewport().add(myJTable);
>
> ?
>
> Ulf
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com