Solved

JTable: How do I make it scrollable?

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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.

707 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