aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes SWING -  gui and xml file structure manipulation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "SWING -  gui and xml file structure manipulation " Watch "SWING -  gui and xml file structure manipulation " New topic
Author

SWING - gui and xml file structure manipulation

shlomy bentulilah
Ranch Hand

Joined: Oct 25, 2007
Posts: 37
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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
shlomy bentulilah
Ranch Hand

Joined: Oct 25, 2007
Posts: 37
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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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

Joined: Oct 25, 2007
Posts: 37
Exactly BUT do it with only 2 buttons : add element/attribute and remove element/attribute...

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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

Joined: Oct 25, 2007
Posts: 37
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 ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SWING - gui and xml file structure manipulation