gla
asked on
change color on a selected text in jEditorPanel
I have a jEditorPanel with setContentType("text/html" ) and some text and I want to set color or change font (html) on selected text or set html code in cursor position.
any idea?
any idea?
ASKER
ok this is true if added the html code..
but i want to insert text (html) like "<strong>" in a cursor position for example:
the text in jEditorPanel is:
language JAVA
the cursor position is between language and java like:
language | java
and when I click on a button the text will change to:
language <strong> java..
but i want to insert text (html) like "<strong>" in a cursor position for example:
the text in jEditorPanel is:
language JAVA
the cursor position is between language and java like:
language | java
and when I click on a button the text will change to:
language <strong> java..
The simplest way is to collect the contents String x = pane.getText();
know the caret position pane.getCaretPosition();
to insert or replace the text you want
and then put it back pane.setText(x);
;JOOP!
know the caret position pane.getCaretPosition();
to insert or replace the text you want
and then put it back pane.setText(x);
;JOOP!
pane.getDocument().insertS tring(pane .getCaretP osition(), your text here);
ASKER
hoomanv
the insertString() has another on option the Attribute
the insertString() has another on option the Attribute
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the comments that help me is the following(I accept wrong comment by mistake):
hoomanv:
http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/index.html
see the TextComponentDemo
http://java.sun.com/docs/books/tutorialJWS/uiswing/components/example-1dot4/TextComponentDemo.jnlp
hoomanv:
pane.getDocument().insertS tring(pane .getCaretP osition(), "your text here", null);
hoomanv:
http://java.sun.com/docs/books/tutorial/uiswing/components/example-1dot4/index.html
see the TextComponentDemo
http://java.sun.com/docs/books/tutorialJWS/uiswing/components/example-1dot4/TextComponentDemo.jnlp
hoomanv:
pane.getDocument().insertS
pane.setSelectedTextColor(
pane.setSelectionColor(Col
;JOOP!