?
Solved

JTable: How do I make it scrollable?

Posted on 2004-10-13
2
Medium Priority
?
336 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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…
Suggested Courses
Course of the Month12 days, 5 hours left to enroll

752 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