Search code examples
javajtableselectioncell

Lines to support selection of cells


I'm using the Netbeans RCP and want to make cell selection in a jtable more visible. Therefore I like to draw red lines like the following:

See screenshot: https://i.sstatic.net/WRRyq.png

I only used GIMP to draw the lines on the screenshot ;-)

When selection increases and more cells are selected, the red lines should be the borders of the selection and should mark the whole width in the columnheader and the whole height in the row header.

My table will be much larger with a fixed columncount of ~35 and undefined count of rows. Does anyone tried something like this before??

Thanks a lot in advance! - Michael


Solution

  • Those may direct you to helpful information. Sorry I cannot provide exact answer to your case.

    Outline view is a big fat JTable, so basically searching for information on parent components will give you more information on internal things.

    org.openide.explorer.view.OutlineView outlineView;

    To enable row selection: outlineView.getOutline().setRowSelectionAllowed(true);

    To define row selection mode: outlineView.getOutline().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    To disable cell selection: outlineView.getOutline().setCellSelectionEnabled(false);