user489041
user489041

Reputation: 28312

Interactive JTable

I would like to create an interactive JTable. For this, I would like to add JPanels in the cells of the table. Once the JPanels are in the cells, I can add my various components to the JPanels thus making the table interactive. Each JPanel could have different components. Would it be possible to accomplish this and only have to create 1 table cell editor and 1 table cell tenderer. Does anyone know of a better way to do it?

Thanks

EDIT: Thanks for the responses. I actually already have a framework I am using. I just needed a JTable that users could drag and drop images in, play movies, display graphs, etc... I already have the functionality to do those things, I just needed a JPanel to add them too. I wanted it to be displayed in a JTable so the cells could be sorted, moved, add/delete rows/col, and well structured. I couldn't get it to work using the JTable, so I went ahead an created my own. Its just a JPanel that contains smaller JPanels (the table cells) using the GridLayout. It works well enough for my puposes. Just a pain to rewrite all of the functionality from scratch that a table has.

Upvotes: 6

Views: 1329

Answers (3)

trashgod
trashgod

Reputation: 205875

JSplitPane may be an alternative in this context: one pane would hold the JTable, while the other displays expanded details of the selected row. A compete example using GridLayout is shown here.

Upvotes: 1

Adamski
Adamski

Reputation: 54725

It sounds like you're trying to use JTable as a docking framework. Assuming this is the case you're better off using something like MyDoggy or JDock which allow you to decompose your GUI into multiple split pane areas.

Upvotes: 3

ordnungswidrig
ordnungswidrig

Reputation: 3186

This is hard. JTable actually uses the cell renderers only for painting the cell content. I would recommend to check if a gridlayout packaged into a scrollpane would be the easier solution.

Upvotes: 5

Related Questions