JTable, JScrollPane & horizontal scroll bars - why?



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
.



Relevant Pages

  • Re: Bad window behavior on a Mac
    ... It appears that he is NOT suffering the "Incomplete Pagination" bug. ... computer's display, you experience the problem less often. ... the window frequently displays improperly. ... When clicking the down arrow of the vertical scroll bar, ...
    (microsoft.public.mac.office.word)
  • Re: Bad window behavior on a Mac
    ... computer's display, you experience the problem less often. ... This forces Word to repaginate the entire document, and in doing so, to ... the window frequently displays improperly. ... When clicking the down arrow of the vertical scroll bar, ...
    (microsoft.public.mac.office.word)
  • Re: how do I turn on the tabs?
    ... Or maybe you dragged the horizontal scroll bar too far to the left and covered ... There's a "grab point" to the left of the horizontal scroll bar's arrow that you ... can use to resize that scroll bar. ... I have two spreadsheets where the tabs have disappeared. ...
    (microsoft.public.excel.misc)
  • Re: Drop Down List
    ... tried one that had list 50 records and the scroll bar was there automatically. ... > That page (when I used the Drop-Down) all were displayed except one. ... > browser has to display the list. ... > | you will see United States and you click the down arrow, ...
    (microsoft.public.frontpage.client)
  • Re: Problems with page set up
    ... Microsoft MVP (Word) ... area indicating the margins)? ... That is also the place to toggle display of the vertical ... but there are still no margins or scroll bar. ...
    (microsoft.public.word.docmanagement)