/** * TreeCellRenderer method. Overridden to update the visible row. */ public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column ) { if (isSelected) { Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); boolean tableHasFocus = (focusOwner == this) || (focusOwner == TreeTable.this) || TreeTable.this.isAncestorOf(focusOwner) || focusOwner instanceof JRootPane; //RootPane == popup menu setBackground(tableHasFocus ? table.getSelectionBackground() : getUnfocusedSelectedBackground()); setForeground(tableHasFocus ? table.getSelectionForeground() : getUnfocusedSelectedForeground()); } else { setBackground(table.getBackground()); setForeground(table.getForeground()); } visibleRow = row; return this; }
/** Repaint the selected row */ private void repaintSelection(boolean focused) { int start = getSelectionModel().getMinSelectionIndex(); int end = getSelectionModel().getMaxSelectionIndex(); if (end != -1) { if (end != start) { Rectangle begin = getCellRect(start, 0, false); Rectangle r = getCellRect(end, 0, false); r.y =begin.y; r.x = 0; r.width = getWidth(); r.height = r.y + r.height - begin.y; repaint (r.x, r.y, r.width, r.height); } else { Rectangle r = getCellRect(start, 0, false); r.width = getWidth(); r.x = 0; repaint (r.x, r.y, r.width, r.height); } } if (isEditing() && editorComp != null) { editorComp.setBackground(focused ? getSelectionBackground() : getUnfocusedSelectedBackground()); editorComp.setForeground(focused ? getSelectionForeground() : getUnfocusedSelectedForeground()); } }
/** Repaint the selected row */ private void repaintSelection(boolean focused) { int start = getSelectionModel().getMinSelectionIndex(); int end = getSelectionModel().getMaxSelectionIndex(); if (end != -1) { if (end != start) { Rectangle begin = getCellRect(start, 0, false); Rectangle r = getCellRect(end, 0, false); r.y =begin.y; r.x = 0; r.width = getWidth(); r.height = r.y + r.height - begin.y; repaint (r.x, r.y, r.width, r.height); } else { Rectangle r = getCellRect(start, 0, false); r.width = getWidth(); r.x = 0; repaint (r.x, r.y, r.width, r.height); } } if (isEditing() && editorComp != null) { editorComp.setBackground(focused ? getSelectionBackground() : getUnfocusedSelectedBackground()); editorComp.setForeground(focused ? getSelectionForeground() : getUnfocusedSelectedForeground()); } }
tableHasFocus ? table.getSelectionForeground() : TreeTable.getUnfocusedSelectedForeground() ); } else {
setForeground(tableHasFocus ? table.getSelectionForeground() : getUnfocusedSelectedForeground()); } else { setBackground(table.getBackground());
setForeground(tableHasFocus ? table.getSelectionForeground() : getUnfocusedSelectedForeground()); } else { setBackground(table.getBackground());
/** Repaint the selected row */ private void repaintSelection(boolean focused) { if (Children.MUTEX.isReadAccess() || Children.MUTEX.isWriteAccess()) { int start = getSelectionModel().getMinSelectionIndex(); int end = getSelectionModel().getMaxSelectionIndex(); if (end != -1) { if (end != start) { Rectangle begin = getCellRect(start, 0, false); Rectangle r = getCellRect(end, 0, false); r.y = begin.y; r.x = 0; r.width = getWidth(); r.height = (r.y + r.height) - begin.y; repaint(r.x, r.y, r.width, r.height); } else { Rectangle r = getCellRect(start, 0, false); r.width = getWidth(); r.x = 0; repaint(r.x, r.y, r.width, r.height); } } if (isEditing() && (editorComp != null)) { editorComp.setBackground(focused ? getSelectionBackground() : getUnfocusedSelectedBackground()); editorComp.setForeground(focused ? getSelectionForeground() : getUnfocusedSelectedForeground()); } } else { new GuardedActions(3, focused); } }
TreeTable.getUnfocusedSelectedForeground());