0

I'm making a program that is some kind of a room manager,

Every day there are different clients in each room and sometimes one room have two shift in it: morning and evening.

I want to, in days that 2 clients are listed at the same room in different shifts, split the cell (which is a JButton) into two buttons, both contained in the same cell and to color every client in its own color.

This is a screen shot of my app:

This is what I've done so far.

And this is what I wish to accomplish:

enter image description here

Any ideas for how can I split the atom like that?

dic19
  • 17,821
  • 6
  • 40
  • 69
David Gidony
  • 1,243
  • 3
  • 16
  • 31
  • 1
    by Renderering JPanel with desired type of JComponents, or possible with default JLabel/JComponent (have to add LayoutManager) – mKorbel Dec 09 '14 at 15:02
  • that would be great, if possible. can you show me an example please ? – David Gidony Dec 09 '14 at 15:24
  • 1
    [simplest as is possible](http://stackoverflow.com/a/6355910/714968), but then you have to create own [JTableHeader](http://stackoverflow.com/a/26861494/714968) (couldn't be important, up to, until RowFilter/Sorter isn't used) – mKorbel Dec 09 '14 at 15:29
  • 1
    You'll need a `CellEditor` for [example](http://stackoverflow.com/a/11179669/230513). – trashgod Dec 09 '14 at 21:50
  • 1
    thanks all, especially @trashgod. post it as an answer , and I will accept it. – David Gidony Dec 10 '14 at 11:08

1 Answers1

2

Your TableCellRenderer can render two buttons in a panel, but you'll also need a TableCellEditor, as shown in this example. Note in particular how each editor overrides getCellEditorValue().

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045