aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Looking for ideas marshalling tables to xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Looking for ideas marshalling tables to xml" Watch "Looking for ideas marshalling tables to xml" New topic
Author

Looking for ideas marshalling tables to xml

Matt Kurz
Ranch Hand

Joined: Jan 02, 2010
Posts: 40
Dear java fans,

I'am searchig for ideas to develop the following:

A GUI to draw tables and change, add, delete it's columns, rows, cells. Also nested tables and columnspan should be possible. The result should be stored in a xml. Something like:

I experimented with JTable and JTree, but until now, I'am not happy with my concept. Maybe it's easier to use only JTree and draw all Tables with Graphics2D Rectangles. I'am not sure. How would you do that?

Regards
mattk1
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19552
    
  16

Maybe you can use both; a JSplitPane with a JTree (or JList if you only have tables) on the right and a JTable for the currently selected table on the right. That's how I've done it before. You can use a CardLayout on the right, or use one single JTable with a changing TableModel.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9993
    
    7

You might also want to consider a tree table


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Matt Kurz
Ranch Hand

Joined: Jan 02, 2010
Posts: 40
I 've already seen the TreeTable example from SUN, but not how it could solve my requirements. Now, after the post of Maneesh Godbole, I studied it again. Some sentences sound, like it could be helpfull, but I will need some more days to understand it so far, that I can manipulate it for my first aim.

@Rob Prime
You wrote: "... or use one single JTable with a changing TableModel."
Does that mean, I can build a TableModel which has cells with JTables(nested), informations about every table/column/row/cell attributes like backgroundcolor, border, width... manipulate it with the existing methods and give it out as xml at the end, over some get methods without something like a tree?


Thanks for your help.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19552
    
  16

No, what I meant is that each element in the tree / list has an associated TableModel. On the right side there is only one single JTable. When you select an element on the left you take its TableModel and set it for the JTable (using the setModel method).
Matt Kurz
Ranch Hand

Joined: Jan 02, 2010
Posts: 40
What about the following? I use only JTable and store ALL informations in something like:


And later, if somebody clicks "Save as" I give it out as xml.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19552
    
  16

Sounds like a plan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Looking for ideas marshalling tables to xml
 
Similar Threads
JTree - Fonts - Threads And CellRenderers
jTree with the TreeModel
JTable In JTree
Need help on JTree
Customising the editor in JTree