Regards,
Amir Kost
Try using HTML. If your Java version is recent, it will work.
--
Paul Lutus
www.arachnoid.com
Amir Kost wrote:
> Hi.
> Can anyone tell me how to wrap text lines JLabel and JList?
With JList this should not be an issue, actually; typically
you have your data stored in a ListModel, for instance:
DefaultListModel model = new DefaultListModel();
model.addElement(....);
JList list = new JList();
Did you check the tutorial with respect to JList/ListModel:
http://java.sun.com/docs/books/tutorial/uiswing/components/list.html
? When your data a stored in a Database this will correspond
to a column in your database, and should neither be a problem.
Linda
--
_ _ /--\ "I can't explain myself, I'm afraid,Sir",
\/_ _ _/(_(_(_o o) said Alice, "because I'm not myself,
(_(_(_(/ ^ you see". I don't see, said the Caterpillar.
Alices Adventures in Wonderland
Amir Kost wrote:
> Hi.
> Can anyone tell me how to wrap text lines JLabel and JList?
With JList this should not be an issue, actually; typically
you have your data stored in a ListModel, for instance:
DefaultListModel model = new DefaultListModel();
model.addElement(....);
JList list = new JList(model);
What I meant is if it is possible to set the width of a JLabel or JList, so
the text will wrap if needed, instead of showing a scroll.
Amir
Amir Kost wrote:
> What I meant is if it is possible to set the width of a JLabel or JList, so
> the text will wrap if needed, instead of showing a scroll.
Even if you restrict the width your text will not wrap. To get a
multiline JLabel you can use HTML, if you like that. But perhaps
you are rather looking for a JTextArea instead of JLabel or JList,
and turn on line-wrap: setLineWrap(true);/setWrapStyleWord(true);
Linda
--
(=)
/ li...@jalice.ch - http://www.jalice.net
(=)
/ l.ra...@hswzfh.ch - http://www.hswzfh.ch
(=)
>
> What I meant is if it is possible to set the width of a JLabel or JList,
so
> the text will wrap if needed, instead of showing a scroll.
>
Use a JTextArea and
- turn on word + line wrapping
- replace the caret with an invisible one
- set the cursor to default (not I-beam)
- install colors and fonts of a Label.
- disable focus traversal
This will look like and feel like a JLabel, but wraps its
contents according the width.
jan