0

I am creating an JOutline that has rooms, and inside each room has multiple products. You can select an individual product and hit details, but I also need to be able to select check boxes next to multiple products using a checkbox.

I am particularly looking for a way to have the checkbox on the far left of the objects.

Is there any way to do this, or am I better of looking into JXTreeTable?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Kyper
  • 1

1 Answers1

1

As discussed here, Outline requires your implementation of the RowModel interface, which should be passed to your OutlineModel constructor.

class MyRowModel implements RowModel {…}
TreeModel myModel = new MyTreeModel(…);
OutlineModel outlineModel = DefaultOutlineModel.createOutlineModel(
    myModel, new MyRowModel(), …);
Outline outline = new Outline();
outline.setModel(outlineModel);

In your implementation of RowModel, follow the familiar JTable edit/render scheme for a model value of type Boolean:

  • The getColumnClass() implementation should return Boolean.class for the relevant column.

  • The isCellEditable() implementation should return true for the relevant column.

  • The getColumnClass() implementation should return the value from the given node in myModel.

  • The setValueFor() implementation should update the given node, so the renderer will see the new value when editing concludes.

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • I actually have it functioning as you've shown above, but I am looking for a way to have the checkbox in the node column, I feel like I need to make a custom Outline that can take a checkbox component in the RenderDataProvider – Kyper Jul 06 '15 at 22:20
  • AFAIK, only `RowModel` decorations are supported. – trashgod Jul 07 '15 at 01:51
  • This was my fear, but I wanted to make sure, thank you for your time. – Kyper Jul 07 '15 at 19:56
  • If you want to check whole subtrees, you can handle it in the model, for [example](http://stackoverflow.com/a/7137801/230513). – trashgod Jul 07 '15 at 21:48