Solved

JTable: How do I make it scrollable?

Posted on 2004-10-13
2
316 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 45
mockito example issue 8 73
going to wrong jsp page 2 22
Is there a simpler dropbox system? 10 24
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…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

822 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