JTable column strange request

I have to build a table with 7 columns, and under one header i have to put a number, a button, a checkbox and to draw some lines.

this is the request of ther customer so i obey.

thing is i have done before adding a component in a cell using TableCellRenderer and TableCellEditor. then i added a single button. but now it seems rather complicated. i tried to do it using g.getGrpahics and drawing the components.

but it does not seem to work.

does anybody has an idea how can i do it ?

I thought of doing a JPanel and adding all the components to it, but i still have the issue with sending the clickas to the JPanel. when it was the button only i used the TableCellEditor, but now it is rather tricky and i do not know how to do it.

please help !

[791 byte] By [asrfela] at [2007-10-3 4:39:44]
# 1
Let's clarify; you want all of these bits and pieces in one table cell?And then you want to be able to edit that cell?And what would "editing" mean in such a cell?
malcolmmca at 2007-7-14 22:43:40 > top of Java-index,Desktop,Core GUI APIs...
# 2

let me reformulate.

i need a way to create a table cell that contains a button and a checkbox and some lines. and i want the button and the checkbox to respond to click events.

p.s. i mentioned the tableCellEditor because this is what i used when i only had a button in a TableCell.

asrfela at 2007-7-14 22:43:40 > top of Java-index,Desktop,Core GUI APIs...
# 3

One thing you could do - and I've not tried this, but it's an idea and I can't immediately see any real problems with it...

Render the cells as normal. Have the concept of a "current" cell. Add a mouse input listener to the table - on mouse moved, check the cell, and switch your "current" cell to that. Your "current" cell is replaced by the actual (compound) component, ie it's added to the table rather than rendered as a cell - overlaid, if you like. So it can respond to mouse events, whilst the rest of the table is rendered as normal, and you don't have to kick the table into 'editing' mode.

itchyscratchya at 2007-7-14 22:43:40 > top of Java-index,Desktop,Core GUI APIs...
# 4
Please could you be a little bit more explicit. :(
asrfela at 2007-7-14 22:43:40 > top of Java-index,Desktop,Core GUI APIs...
# 5

You have a component class for rendering the cell, I assume? Let's call it "MyCellComponent."

Your mouse listener tells you where the user has moved the cursor to within the table, right?

So, you know the cell. You then *add* a MyCellComponent to the table and set its bounds to match those of the relevant cell, revalidate and repaint the table. It should look just as before, but now those buttons etc are actually there, not just rendered. The user can interact with them.

If the user moves the cursor back out of that cell then your mouse listener will tell you they're in a new cell - you remove your old cell component and replace it with a new one (or, better, reconfigure the existing one as you should for cell rendering purposes anyway) with the bounds set to those of the new cell.

I'm not writing your code for you if that's what you mean by 'explicit' :o)

itchyscratchya at 2007-7-14 22:43:40 > top of Java-index,Desktop,Core GUI APIs...
# 6
thank you very much for the explaining.and i was not talking about you writing my code.
asrfela at 2007-7-14 22:43:40 > top of Java-index,Desktop,Core GUI APIs...