Solved

JTable: How do I make it scrollable?

Posted on 2004-10-13
2
331 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
[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
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

737 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