How to italic some texts in a JList

S

shoa

Hello all

I have JList with texts (I use labels for texts). Now I want to have some
texts are italic, some are not. Could you please tell me how to do that

Thank you for your help
SHoa
 
V

VisionSet

shoa said:
Hello all

I have JList with texts (I use labels for texts). Now I want to have some
texts are italic, some are not. Could you please tell me how to do that

Read the API docs, JList extends JComponent, which has setFont(Font).
 
A

Andrew Thompson

....
Read the API docs, JList extends JComponent, which has setFont(Font).

That would be the best way to go for italic,
but if you needed something a little more,
you could also use HTML as the text..

<html><body>
<p><i>italic <b>bold</b></i> text<sup>2</sup></p>
</body></html>

Note though, that the JVM needs to load
a larger number more classes before it
can render HTML, so Mike's method should
be significantly faster.
 
R

Roedy Green

That would be the best way to go for italic,
but if you needed something a little more,
you could also use HTML as the text..

The super fast approach, is to render with drawString in your own
custom component. I posted an paint method yesterday that could be
used to do generic text painting in a variety of fonts, styles,
colours and sizes.


The disadvantage is that the user cannot select/copy/paste. The
result is a bit image the end user cannot manipulate or update.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top