JTable, JScrollPane & horizontal scroll bars - why?
- From: "A. W. Dunstan" <no@xxxxxxxxxxx>
- Date: Fri, 09 Nov 2007 17:00:21 -0500
I need to display a JTable. In this case the width of each cell in the last
column varies - it's a collection of text & color swatches, represented by
JLabels and JPanels stuffed into a containing JPanel.
I can get a vertical scroll bar to appear by putting enough entries in the
table, but no matter what the width of my columns it never puts in a
horizontal scroll bar. Yes, I can force one by setting AUTO_RESIZE_OFF but
then I *always* get a horizontal scrollbar, even when I don't need one.
Also, the table always starts out much too narrow to display the entire
line, scroll bar or not. I'd really like to get either a scroll bar, or
for the table to resize wide enough to show the longest line.
The least-worst solution I've found so far is to force a scroll bar and add
a ComponentListener to listen for changes in the size of the JComponent
containing the JScrollPane, and resize the width of the last column
accordingly.
Is there a better way of doing horizontal scroll bars in a JTable?
--
Al Dunstan, Software Engineer
OptiMetrics, Inc.
3115 Professional Drive
Ann Arbor, MI 48104-5131
.
- Follow-Ups:
- Re: JTable, JScrollPane & horizontal scroll bars - why?
- From: Rich Sweeny
- Re: JTable, JScrollPane & horizontal scroll bars - why?
- Prev by Date: Java Swing font anti-aliasing w/o desktop environment
- Next by Date: Re: Graphics and JVMs
- Previous by thread: Java Swing font anti-aliasing w/o desktop environment
- Next by thread: Re: JTable, JScrollPane & horizontal scroll bars - why?
- Index(es):
Relevant Pages
|
|