Solved

how to resize columns of a JTable to automatically fit content

Posted on 2003-10-26
4
761 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
wordcount challenge 11 78
Running Jira on Raspberry PI 2? 3 139
Java passing arguments (type error) 2 35
Java Jpanels and Jframe 8 21
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…
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 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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now