Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #2742 > unrolled thread
| Started by | "A. W. Dunstan" <a..w..dunstan@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:40 +0000 |
| Last post | 2011-04-27 15:40 +0000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.java.gui
JTable, JScrollPane & hor "A. W. Dunstan" <a..w..dunstan@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: JTable, JScrollPane & "Rich Sweeny" <rich.sweeny@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: JTable, JScrollPane & "A. W. Dunstan" <a..w..dunstan@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
| From | "A. W. Dunstan" <a..w..dunstan@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:40 +0000 |
| Subject | JTable, JScrollPane & hor |
| Message-ID | <qoadnYjJFqflRananZ2dnUVZ_gudnZ2d@speakeasy.net> |
To: comp.lang.java.gui 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 --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Rich Sweeny" <rich.sweeny@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:40 +0000 |
| Subject | Re: JTable, JScrollPane & |
| Message-ID | <Bi9Zi.249$0w2.216@newsfe08.lga> |
| In reply to | #2742 |
To: comp.lang.java.gui A. W. Dunstan wrote: > 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? > > There are 3 constants: HORIZONTAL_SCROLLBAR_NEVER HORIZONTAL_SCROLLBAR_AS_NEEDED HORIZONTAL_SCROLLBAR_ALWAYS or VERTICAL_SCROLLBAR_NEVER VERTICAL_SCROLLBAR_AS_NEEDED VERTICAL_SCROLLBAR_ALWAYS Example: This will always give you a vertical and never a horizontal: JScrollPane scroll = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); Rich --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "A. W. Dunstan" <a..w..dunstan@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:40 +0000 |
| Subject | Re: JTable, JScrollPane & |
| Message-ID | <FN-dnUotJ_hjF6XanZ2dnUVZ_jqdnZ2d@speakeasy.net> |
| In reply to | #2745 |
To: comp.lang.java.gui Rich Sweeny wrote: > A. W. Dunstan wrote: >> 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? >> >> > > There are 3 constants: > HORIZONTAL_SCROLLBAR_NEVER > HORIZONTAL_SCROLLBAR_AS_NEEDED > HORIZONTAL_SCROLLBAR_ALWAYS > or > VERTICAL_SCROLLBAR_NEVER > VERTICAL_SCROLLBAR_AS_NEEDED > VERTICAL_SCROLLBAR_ALWAYS > > Example: This will always give you a vertical and never a horizontal: > > JScrollPane scroll = new JScrollPane(table, > JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, > JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); > > Rich The defaults for JScrollPane(Component) are *_SCROLLBAR_AS_NEEDED. -aI needed one, but never got one. -- Al Dunstan, Software Engineer OptiMetrics, Inc. 3115 Professional Drive Ann Arbor, MI 48104-5131 --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web