Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2582

Re: JTextArea size proble

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Larry Barowski" <larry.barowski@THRWHITE.remove-dii-this>
Subject Re: JTextArea size proble
Message-ID <ftKdnZ040MnVIZ7anZ2dnUVZ_o6knZ2d@comcast.com> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <470376e5$0$13927$fa0fcedb@news.zen.co.uk>
References <470376e5$0$13927$fa0fcedb@news.zen.co.uk>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 28
Date Wed, 27 Apr 2011 15:39:57 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918797 96.60.20.240 (Wed, 27 Apr 2011 10:39:57 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:39:57 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:2582

Show key headers only | View raw


  To: comp.lang.java.gui

"RedGrittyBrick" <redgrittybrick@spamweary.foo> wrote in message 
news:470376e5$0$13927$fa0fcedb@news.zen.co.uk...
> In a dialogue box, I want to display some text word-wrapped. I use a 
> JTextArea and set word wrapping on.
>
> However, the height of the dialogue seems to be incorrectly based on the 
> Textarea being one line high, (it is two lines high when wrapped).

During layout, the text area doesn't know what its eventual width will
be, so it has no way to provide a useful preferred height. It's a problem
for any component for which the preferred size in one dimension
depends on the actual size in the other. This might be good enough to
solve your problem (replacement for pack()):

  pack();
  messageComponent.setSize(messageComponent.getPreferredSize());
  pack();

You could write your own word-wrapping label class from scratch,
but there is no way to solve the basic problem of height/width
dependence. A double pack(), at least, would still be required.

---
 * 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

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

JTextArea size problem. "RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this> - 2011-04-27 15:39 +0000
  Re: JTextArea size proble "Larry Barowski" <larry.barowski@THRWHITE.remove-dii-this> - 2011-04-27 15:39 +0000
  Re: JTextArea size proble "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000

csiph-web