Solved

how to resize columns of a JTable to automatically fit content

Posted on 2003-10-26
4
781 Views
Last Modified: 2007-12-19
hi,
i have a jtable, that has three columns. in the first two there is only a number, the last one contains a string. right now every column hast the same size and there is not enough space for the string. how can i make the table to decrease the the with for the first two columns?
0
Comment
Question by:honkinamiland
  • 3
4 Comments
 
LVL 15

Accepted Solution

by:
jimmack earned 150 total points
ID: 9623934
Try setPreferredWidth (from TableColumn) for the first two columns.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9623935
and doLayout in JTable (sorry.  That should all have been in one post)
0
 

Author Comment

by:honkinamiland
ID: 9623964
ok, i needed also to set the max width to make it work, but that's it.
thanks
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9623971
Just in case you need more, there's a good example here:

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#custom

It's the example after the "Version note" after this heading.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
oracle 11g 23 83
fibonacci ten numbers 4 38
How to execute a Python program and gather return output in Java 2 30
Which non-HTML GUI front end to use with Java? 3 22
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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
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 covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

773 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