/** Overridden to manually draw the focused rectangle for the tree column */ @Override public void paintComponent(Graphics g) { super.paintComponent(g); if (hasFocus() && (getSelectedColumn() == 0) && (getSelectedRow() > 0)) { Color bdr = UIManager.getColor("Tree.selectionBorderColor"); //NOI18N if (bdr == null) { //Button focus color doesn't work on win classic - better to //get the color from a value we know will work - Tim if (getForeground().equals(Color.BLACK)) { //typical bdr = getBackground().darker(); } else { bdr = getForeground().darker(); } } g.setColor(bdr); Rectangle r = getCellRect(getSelectedRow(), getSelectedColumn(), false); g.drawRect(r.x + 1, r.y + 1, r.width - 3, r.height - 3); } }
/** Overridden to manually draw the focused rectangle for the tree column */ public void paintComponent(Graphics g) { super.paintComponent(g); if (hasFocus() && getSelectedColumn() == 0 && getSelectedRow() > 0) { Color bdr = UIManager.getColor("Tree.selectionBorderColor"); //NOI18N if (bdr == null) { //Button focus color doesn't work on win classic - better to //get the color from a value we know will work - Tim if (getForeground().equals(Color.BLACK)) { //typical bdr = getBackground().darker(); } else { bdr = getForeground().darker(); } } g.setColor(bdr); Rectangle r = getCellRect (getSelectedRow(), getSelectedColumn(), false); g.drawRect(r.x+1, r.y+1, r.width - 3, r.height - 3); } }
/** Overridden to manually draw the focused rectangle for the tree column */ public void paintComponent(Graphics g) { super.paintComponent(g); if (hasFocus() && getSelectedColumn() == 0 && getSelectedRow() > 0) { Color bdr = UIManager.getColor("Tree.selectionBorderColor"); //NOI18N if (bdr == null) { //Button focus color doesn't work on win classic - better to //get the color from a value we know will work - Tim if (getForeground().equals(Color.BLACK)) { //typical bdr = getBackground().darker(); } else { bdr = getForeground().darker(); } } g.setColor(bdr); Rectangle r = getCellRect (getSelectedRow(), getSelectedColumn(), false); g.drawRect(r.x+1, r.y+1, r.width - 3, r.height - 3); } }
/** Utility method which performs configuration which is common to all of the renderer * implementations - sets the icon and focus properties on the renderer * from the VisualizerNode. * */ private int configureFrom (HtmlRenderer.Renderer ren, Container target, boolean useOpenedIcon, boolean sel, VisualizerNode vis) { Icon icon = vis.getIcon(useOpenedIcon, bigIcons); if (icon.getIconWidth() > 0) { //Max annotated icon width is 24, so to have all the text and all //the icons come out aligned, set the icon text gap to the difference //plus a two pixel margin ren.setIconTextGap (24 - icon.getIconWidth()); } else { //If the icon width is 0, fill the space and add in //the extra two pixels so the node names are aligned (btw, this //does seem to waste a frightful amount of horizontal space in //a tree that can use all it can get) ren.setIndent (26); } ren.setIcon (icon); if (target instanceof TreeTable.TreeTableCellRenderer) { TreeTable tt = ((TreeTable.TreeTableCellRenderer) target).getTreeTable(); ren.setParentFocused (tt.hasFocus() || tt.isEditing()); } return icon.getIconWidth() == 0 ? 24 : icon.getIconWidth(); }
/** Utility method which performs configuration which is common to all of the renderer * implementations - sets the icon and focus properties on the renderer * from the VisualizerNode. * */ private int configureFrom (HtmlRenderer.Renderer ren, Container target, boolean useOpenedIcon, boolean sel, VisualizerNode vis) { Icon icon = vis.getIcon(useOpenedIcon, bigIcons); if (icon.getIconWidth() > 0) { //Max annotated icon width is 24, so to have all the text and all //the icons come out aligned, set the icon text gap to the difference //plus a two pixel margin ren.setIconTextGap (24 - icon.getIconWidth()); } else { //If the icon width is 0, fill the space and add in //the extra two pixels so the node names are aligned (btw, this //does seem to waste a frightful amount of horizontal space in //a tree that can use all it can get) ren.setIndent (26); } ren.setIcon (icon); if (target instanceof TreeTable.TreeTableCellRenderer) { TreeTable tt = ((TreeTable.TreeTableCellRenderer) target).getTreeTable(); ren.setParentFocused (tt.hasFocus() || tt.isEditing()); } return icon.getIconWidth() == 0 ? 24 : icon.getIconWidth(); }