Solved

JTable: How do I make it scrollable?

Posted on 2004-10-13
2
297 Views
Last Modified: 2008-01-09
Hi,

I've made a JTable (from the SimpleTableDemo at http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#show)

Anyhow... I've populated it with a few hundred rows and cols.

But it writes most of them with '...'

How do I get to view the entire column heading (not '...') as well as all the data in the cells?

And how can I scroll over to the last column. There is no horizontal scroll bar.

Is this something to do with the ScrollPane?
0
Comment
Question by:ycomp
  • 2
2 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 500 total points
ID: 12300919
   // Create a table with 10 rows and 5 columns
    JTable table = new JTable(10, 5);
   
    // Make the table vertically scrollable
    JScrollPane scrollPane = new JScrollPane(table);

By default, a table is created with auto resize enabled. This means that if the user changes the width of the table, the columns automatically expand or shrink so that all the columns are entirely visible. In this mode, there is no need for a horizontal scrollbar. In order to get horizontal scrolling, auto resize must be disabled.

    // Disable auto resizing to make the table horizontal scrollable
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12301645
Thanks for accepting  
:-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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 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 will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

760 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

20 Experts available now in Live!

Get 1:1 Help Now