Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SWING - gui and xml file structure manipulation

 
shlomy bentulilah
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have xml file that I want to present in my gui.
I also want to give the user an option to add elements and attributes and also to be able to delete them.
How do you think I should imlement this requierment?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JTree is generally the best way to represent XML. A JTree can have editable nodes or you could provide forms for managing attributes for each node.
 
shlomy bentulilah
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replay .

I forgot to mentioned that I want to keep the "look" of the xml file , meaning <ELEMENT @ATTRIBUTE /> and so on , in my GUI.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shlomy bentulilah wrote:Thanks for your replay .

I forgot to mentioned that I want to keep the "look" of the xml file , meaning <ELEMENT @ATTRIBUTE /> and so on , in my GUI.


So you want to just let the user edit it like they might in notepad or vim or whatever? Just in a Java application instead?
 
shlomy bentulilah
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly BUT do it with only 2 buttons : add element/attribute and remove element/attribute...

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shlomy bentulilah wrote:Exactly BUT do it with only 2 buttons : add element/attribute and remove element/attribute...



I won't be of much help with this matter then. I suspect you are going to need to look into the JEditorPane and Document interfaces so that you can figure out where your cursor is, where you need to insert new elements, etc. Something I have never done.
 
shlomy bentulilah
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you think about this one :

1.Reformat my xml file to HTML text when each element and atrribute will be html hyperlink.
2.With the JEditorPane I will load these elements and attributes and use the hyperlinkUpdate to do my delete/add actions.

Do you know if I can do some html manipulations such as changing to color of the hyperlink ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic