0

Can I easily make a java.awt.List multi line for each cell?

E.G. if the cell contains "Hello" It will be height of say 5, and if it contains a considerably longer string "Hello there good day sir" it would adjust the height to 10 and place the remainder on the next line but still be the same selection?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Nathan Headley
  • 152
  • 1
  • 13
  • 1
    Not sure about `java.awt.List` (that's pretty ancient anyway), but with `javax.swing.JList` (that's a little newer) one can use a custom cell renderer capable of multi-line display. The renderer can be e.g. based on a `JTextArea`, as is described here: http://stackoverflow.com/questions/2152742/java-swing-multiline-labels – david a. Mar 07 '17 at 14:39
  • 1) Why use AWT? See [this answer](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) for many good reasons to abandon AWT components in favor of Swing. 2) *"Can I easily make a java.awt.List multi line for each cell?"* No. – Andrew Thompson Mar 07 '17 at 23:03

0 Answers0