Solved

ScrollPane and Table

Posted on 2004-10-11
15
252 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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 about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

832 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