简体   繁体   中英

Java Swing JTextArea Horizontal Constraint only

Is there a way in java swing to code:

"Constraint the width of JTextArea to W but allow JTextArea to expand vertically to contain all the linewrapped text'?

  1. Set the text area to W columns.
  2. Set the wrap style & line wrap.
  3. Add it to a scroll pane with a vertical scroll bar as needed, but no horizontal scroll bar.

Alternately if the content does not need to be selectable or editable, use a label with HTML & CSS to constrain the width.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM