• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to insert a component to JTextPane while this JTextPane displays HTML

 
Anh Chu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a JTextPane displays HTML document. Now, I want to insert a component into this HTML document, but I can't. Please tell me how to do this.
Thanks much in advance!
Tuan Anh
 
Michael Finney
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you ever find out how?
 
King Tan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a JTextPane's insertComponent(Component) method.
Or you can insert into TextPane's document.
Component myComponent = new MyComponent();
Style style = myTextPane.addStyle("comp", null);
StyleConstants.setComponent(style, myComponent);
Document doc = myTextPane.getDocument();
doc.inserString(doc.getLength(), " ", doc.getStyle("comp"));
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!