I have this kind of progamming task without JavaFx, instead it’s Java Swing. I realized my knowledge is still limited.
I have one single JTable.
But, within this JTable I need a custome Cell Renderer.
The goal is to make this kind of JTable: Example image
My current solutions are: Example Image
- Create a Single JTable:
- get each Column and set its CellRenderer with a custom Renderer (below).
- Create a new Class implements TableCellRenderer:
- return different JPanel inside getTableCellRendererComponent
method using switch case (as column counted).
- return different JPanel inside getTableCellRendererComponent
After hours, and hours, I think my current solutions is quite daunting tasks. Thus, My question is:
What are the simplest method of creating this Custom JTable to achieve the main goal as mentioned above?
I’ve been facing this problem for a while, and I decided to do it myself. Extending the existing implementation of a table, adding some concepts for what I expect from a table, and writting some editors/listeners for that. All the same, but with a treetable.
I’m working on this project called SUMI.
It contains a java package (ar.com.tellapic.sumi.treetable) that is an extension of a
JXTreeTablefrom SwingLabs.The project is being developed and I didn’t provide any documentation yet. You can do what you want by creating a renderer and if needed, an editor, for lastly attaching actions to each object.
If you decide to use it and you need help, email me, I’ll help you without any problem.
Or, you could read the source by your own.
Regards,
EDITED (again):
To clear a little bit this answer, I’ve just created a wiki page in the project wiki and put the relevant code there. If someone feels that the code should be inserted here, please let me know.
Basically, I try to explain how to find a straight solution to the renderer/editor problems you may find using
JTablewith your specifics needs by using part of my project, in order to get something like this:Note that the screenshot was taken after clicking on the respective tick-button.