This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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?
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.
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.
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?
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).
Joined: Jan 02, 2010
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.