Solved

ScrollPane and Table

Posted on 2004-10-11
15
250 Views
Last Modified: 2010-08-05
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
0
Comment
Question by:nphnhi
  • 8
  • 3
  • 2
15 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12275641
If you just place your table in a JScrollPane you should have vertical as well as horizontal scrollbars
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12275650
...automatically
0
 
LVL 37

Accepted Solution

by:
zzynx earned 100 total points
ID: 12275667
JScrollPane yourScrollPane = new JScrollPane();
yourScrollPane.setViewportView(yourTable);

whateverComponent.add( yourScrollPane );  // instead of yourTable
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12275686
you can explicitly
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12275711
Not really needed.
The JScrollPane constructor without any paremeters creates a JScrollPane where both horizontal and vertical scrollbars appear when needed
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12275731
i know that,
incase you want to have always then you can use above policy enforced.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 37

Expert Comment

by:zzynx
ID: 12275770
>>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)
0
 
LVL 6

Expert Comment

by:expertmb
ID: 12275795
>>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.
0
 

Author Comment

by:nphnhi
ID: 12275834
No, I mean with 20colums, we can see 10 colums, and user srollbar (horizontal) to srcoll to view the rest
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12275842
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)
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12275860
>> 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
0
 

Author Comment

by:nphnhi
ID: 12276105
I found an example :)
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12276119
What do you mean by that?
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now