Solved

ScrollPane and Table

Posted on 2004-10-11
15
251 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java 1603 Error 3 50
groovy example issue 10 88
starter POM and spring-boot-starter,  spring-boot-web 2 40
use lov values 2 18
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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…

932 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

12 Experts available now in Live!

Get 1:1 Help Now