Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JComponents  RSS feed

 
Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

You see i have some embedded JComponents in a JTextPane, now
what i want i want to do is remove the embedded components and then add
them back to their original location(i.e where i got them from in the
first palce)

You see to get the all JComponents i do this



I have a feeling that i should not be using the
TextPane1.add(); set of methods but i am really not sure what else to use
to insert the JComponent to the original place in the document where i got
it from.

I really hope someone can help me with this problem

Thank You

Yours Sincerely

Richard West
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have access to components in a JTextPane via its StyledDocument. The tutorial TextSamplerDemo shows how to add a JButton to a Style in a StyledDocument. The StyleConstants class has get/setComponent methods that you might be able to use for this.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!