How would I set only a part of the text as italics?
Example: Here is some text...
Printable View
How would I set only a part of the text as italics?
Example: Here is some text...
Step 1, read the text or parse it or tokenize it. Recognize the part that you want, then format it.
Your question is impossible to answer without some context. What exactly are you talking about? A Swing GUI? An Android application? Text in an RTF file? Please tell us the details and show some code.
Swing GUI. Keep in mind I know little Java.
So, then let me get this straight, you want to display text in a Swing GUI where a selected section of the text is italicized, correct?
If so, the easy way to do this is to use HTML markup language to change the font, but note that this won't work in all situations, and I believe for instance that it won't work on a JTextArea for instance. If you want a textarea type of text component, then you may wish to look into using a JTextPane or a JEditorPane. The tutorials will show you how to use them and their styled documents.
I am using a JTextFeild, I want only a part of the text to be italicised
Actually AWT, SWT among others could be used...For the how...Ask the experts. lol.
There are many ways how this can be done:
1) read the API for the Font class; it has italics versions of every possible font;
2) alternatively, use <html> tags for text components (e.g. JLabels);
3) use shearing on your Graphics device.
4) etc.?
kind regards,
Jos
ok, but this still don't give me an answer as to how to accomplish what i'm trying to do with any other component. I'm looking for a solution, not all the things that are wrong what i'm doing.