Link to home
Start Free TrialLog in
Avatar of nphnhi
nphnhi

asked on

ScrollPane and Table

Hello,
I have a table (colums and rows not fixed), but table's size is fixed. Now I want to have a scrollpane in both horizontal side and vertical size. I saw several examples which have a scrollpane just in vertical size.
For exp, my table have 20 colums, and 40 rows. Now, in viewport, we can see 10 colums and 20 rows, so I'd like to  use scrollpane to view all table.
Please help me as soon as possible
Thanks a lot
NN
Avatar of zzynx
zzynx
Flag of Belgium image

If you just place your table in a JScrollPane you should have vertical as well as horizontal scrollbars
...automatically
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of expertmb
expertmb

you can explicitly
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
Not really needed.
The JScrollPane constructor without any paremeters creates a JScrollPane where both horizontal and vertical scrollbars appear when needed
i know that,
incase you want to have always then you can use above policy enforced.
>>incase you want to have always then you can use above policy enforced.
Incorrect. Then you can

yourScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
yourScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

( xxx_ALWAYS instead of xxx_AS_NEEDED)
>>Incorrect. Then you can
zzynx,
dont go by literally, what i said is you can explicilty set the scrollbar policy to ALWAYS
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS

and i know the syntax also.
Avatar of nphnhi

ASKER

No, I mean with 20colums, we can see 10 colums, and user srollbar (horizontal) to srcoll to view the rest
Sorry, but this is what you said:

>>you can explicitly
>>JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
>>JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED

(remark:  xxx_AS_NEEDED)

I think a correction was needed for the author of this question not to be mislead. (no offence meant)
>> No, I mean with 20colums, we can see 10 colums, and user srollbar (horizontal) to srcoll to view the rest
The number of columns is irrelevant. The scrollbars will appear ***when needed***.
That means: as much columns as possible will be shown. The rest of the columns will be "reachable" by scrolling
Avatar of nphnhi

ASKER

I found an example :)
What do you mean by that?