Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ScrollPane and Table

Posted on 2004-10-11
15
Medium Priority
?
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 total points
ID: 12275667
JScrollPane yourScrollPane = new JScrollPane();
yourScrollPane.setViewportView(yourTable);

whateverComponent.add( yourScrollPane );  // instead of yourTable
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
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
 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

688 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