| | |
jtextpane help please..
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2007
Posts: 14
Reputation:
Solved Threads: 0
i have a jtextpane now, i want that some text on it become bold, and not all
how can i possibly do this,
for exmple, i want to bold all the word "cool" found in my textpane..
i know that i should use a DocumentListener(Do I need??)
but i really want to know how to bold certain word found in my textpane, in this case
the word
"cool"
thanks for helping..
this is my code so far, and i dont know what to do
how can i possibly do this,
for exmple, i want to bold all the word "cool" found in my textpane..
i know that i should use a DocumentListener(Do I need??)
but i really want to know how to bold certain word found in my textpane, in this case
the word
"cool"
thanks for helping..
this is my code so far, and i dont know what to do
Java Syntax (Toggle Plain Text)
JTextPane JTP; StyledDocument dsd=new DefaultStyledDocument(); SimpleAttributeSet a=new SimpleAttributeSet(); a.addAttribute(StyleConstants.CharacterConstants.Bold,Boolean.TRUE); try { dsd.insertString(dsd.getLength(),"cool",a); } catch(Exception e) { } JTP=new JTextPane(dsd); getContentPane().add(new JScrollPane(JTP));
Would be nice that you share it with others then...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- JTextPane (Java)
- Printing JPanel containing JLable, JTable, JButton, JTextPane, JTextArea (Java)
- JTextPane (Java)
- adding Jscrollbar or Jscrollpane to Jtextpane (Java)
- JTextPane (Java)
- help with regex...and marking up text in JTextpane with html (Java)
- JTextPane Printing (Java)
Other Threads in the Java Forum
- Previous Thread: Convert String to an expression.
- Next Thread: J2ME build settings in NetBeans
Views: 1141 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application apps arguments array arrays automation binary bluetooth businessintelligence card chat class classes client code collision component crashcourse database draw eclipse ee error event exception file fractal free game gis givemetehcodez graphics gui helpwithhomework html ide image input integer integration j2me java javadoc javafx javaprojects jmf jni jpanel julia jvm linux list loop machine map method methods migrate mobile netbeans newbie nls number object oracle physics print problem program programming project radio recursion scanner screen security server service set size sms socket software sort sql string swing test textfield threads time transfer tree trolltech utility windows






