TableView isn't really designed to support single-cell selection, though it is 
possible to implement a single-cell editor.

On Sep 15, 2011, at 11:48 AM, prophe wrote:

> Hi, all. I want to realize a cell selection in table View. I try to rewrite
> TerraTableViewSkin, but some my cells is never highlighted and I can't
> understand why... I add a few line of code in TerraTableViewSkin in paint
> method:
> 
> ..................................................................
> // Paint the cells
>            columnX = 0;
> 
>            for (int columnIndex = 0, columnCount = columns.getLength();
> columnIndex < columnCount; columnIndex++) {
>               
> 
>               boolean cellHighlighted = (columnIndex==highlightColumnIndex);
>               
>               Color cellBackgroundColor = null;
>               
>                if (cellHighlighted && rowHighlighted){
>                       System.out.println("cellBackgroundColor");
>                    cellBackgroundColor = (tableView.isFocused())
>                            ? this.selectionCellBackgroundColor :
> inactiveCellSelectionBackgroundColor;
>                }
> 
>                int columnWidth = columnWidths.get(columnIndex);
> 
>                if (cellBackgroundColor!=null){
>                    graphics.setPaint(cellBackgroundColor);
>                    graphics.fillRect(columnX, rowY, columnWidth,
> rowHeight);
>                }
>               
>                TableView.Column column = columns.get(columnIndex);
> ..........................................................................................
> and in mouseMove method:
> 
>    @Override
>    public boolean mouseMove(Component component, int x, int y) {
>        boolean consumed = super.mouseMove(component, x, y);
> 
>        TableView tableView = (TableView)getComponent();
> 
>        int previousHighlightRowIndex = this.highlightRowIndex;
>        highlightRowIndex = getRowAt(y);
> 
>        int previousHighlightColumnIndex = this.highlightColumnIndex;
>        highlightColumnIndex = getColumnAt(x);
> 
>        if (previousHighlightRowIndex != highlightRowIndex
>            && tableView.getSelectMode() != TableView.SelectMode.NONE
>            && showHighlight) {
>            if (previousHighlightRowIndex != -1) {
>                repaintComponent(getRowBounds(previousHighlightRowIndex));
>            }
> 
>            if (highlightRowIndex != -1 ) {
>                repaintComponent(getRowBounds(highlightRowIndex));
>            }
>        }
> 
>        if (highlightColumnIndex != previousHighlightColumnIndex
>                && showHighlight){
>               
>               repaintComponent(getRowBounds(previousHighlightColumnIndex));
>               System.out.println("column index - " + highlightColumnIndex);
>               
>               if (highlightColumnIndex != -1) {
>                repaintComponent(getRowBounds(highlightColumnIndex));
>            }
>        }
> 
>        return consumed;
>    }
> 
> But some of my cells is never highlighted on mouse move... My code to look
> at and to test 
> http://perdunov.net/pivotcellteable.rar here 
> Please help me...
> 
> 
> 
> 
> -----
> Thank you!
> --
> View this message in context: 
> http://apache-pivot-users.399431.n3.nabble.com/Cell-selection-in-TableView-tp3339330p3339330.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Reply via email to