Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Looking for ideas marshalling tables to xml

 
Matt Kurz
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might also want to consider a tree table
 
Matt Kurz
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a plan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic