Java Code Examples for javax.swing.tree.DefaultTreeCellRenderer#setBorderSelectionColor()

The following examples show how to use javax.swing.tree.DefaultTreeCellRenderer#setBorderSelectionColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JTreeTable.java    From libreveris with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * updateUI is overridden to set the colors of the Tree's renderer to
 * match that of the table.
 */
@Override
public void updateUI ()
{
    super.updateUI();

    // Make the tree's cell renderer use the table's cell selection
    // colors.
    TreeCellRenderer tcr = getCellRenderer();

    if (tcr instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);

        // For 1.1 uncomment this, 1.2 has a bug that will cause an
        // exception to be thrown if the border selection color is
        // null.
        dtcr.setBorderSelectionColor(null);
        dtcr.setTextSelectionColor(
                UIManager.getColor("Table.selectionForeground"));
        dtcr.setBackgroundSelectionColor(
                UIManager.getColor("Table.selectionBackground"));
    }
}
 
Example 2
Source File: JTreeTable.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * updateUI is overridden to set the colors of the Tree's renderer to
 * match that of the table.
 */
@Override
public void updateUI ()
{
    super.updateUI();

    // Make the tree's cell renderer use the table's cell selection
    // colors.
    TreeCellRenderer tcr = getCellRenderer();

    if (tcr instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);

        // For 1.1 uncomment this, 1.2 has a bug that will cause an
        // exception to be thrown if the border selection color is
        // null.
        dtcr.setBorderSelectionColor(null);
        dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
        dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
    }
}
 
Example 3
Source File: ExplorerNodeRenderer.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    Component renderer = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    ExplorerNode dsn = (ExplorerNode)value;
    JLabel rl = (JLabel)renderer;
    rl.setText(dsn.getName());
    rl.setIcon(dsn.getIcon());
    
    DataSource ds = dsn.getUserObject();
    if (ds instanceof Stateful) {
        rl.setEnabled(((Stateful)ds).getState() == Stateful.STATE_AVAILABLE);
    } else {
        rl.setEnabled(true);
    }

    if (UISupport.isGTKLookAndFeel() || UISupport.isNimbusLookAndFeel()) {
        if (renderer instanceof DefaultTreeCellRenderer) {
            DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer)renderer;
            dtcr.setBackgroundSelectionColor(null);
            dtcr.setBorderSelectionColor(null);
        }
    } else if (UISupport.isAquaLookAndFeel()) {
        if (!sel) {
            rl.setOpaque(true);
            rl.setBackground(tree.getBackground());
        } else {
            rl.setOpaque(false);
        }
    }

    return renderer;
}
 
Example 4
Source File: GroupedBandChoosingStrategy.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public JPanel createCheckersPane() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    Map<String, Integer> groupNodeMap = initGrouping(root);
    List<TreePath> selectedPaths = new ArrayList<>();
    addBandCheckBoxes(root, selectedPaths, groupNodeMap);
    addTiePointGridCheckBoxes(root, selectedPaths, groupNodeMap);
    removeEmptyGroups(root, groupNodeMap);

    TreeModel treeModel = new DefaultTreeModel(root);

    checkBoxTree = new CheckBoxTree(treeModel);
    checkBoxTree.getCheckBoxTreeSelectionModel().setSelectionPaths(selectedPaths.toArray(new TreePath[selectedPaths.size()]));
    checkBoxTree.setRootVisible(false);
    checkBoxTree.setShowsRootHandles(true);
    checkBoxTree.getCheckBoxTreeSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            updateCheckBoxStates();
        }
    });
    final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) checkBoxTree.getActualCellRenderer();
    renderer.setFont(SMALL_ITALIC_FONT);
    renderer.setLeafIcon(null);
    renderer.setOpenIcon(null);
    renderer.setClosedIcon(null);
    Color color = new Color(240, 240, 240);
    checkBoxTree.setBackground(color);
    renderer.setBackgroundSelectionColor(color);
    renderer.setBackgroundNonSelectionColor(color);
    renderer.setBorderSelectionColor(color);
    renderer.setTextSelectionColor(Color.BLACK);

    GridBagConstraints gbc2 = GridBagUtils.createConstraints("insets.left=4,anchor=WEST,fill=BOTH");
    final JPanel checkersPane = GridBagUtils.createPanel();
    GridBagUtils.addToPanel(checkersPane, checkBoxTree, gbc2, "weightx=1.0,weighty=1.0");
    return checkersPane;
}
 
Example 5
Source File: SynthTreeUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 6
Source File: SynthTreeUI.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 7
Source File: SeaGlassTreeUI.java    From seaglass with Apache License 2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer, DefaultTreeCellRenderer dtcr, SeaGlassContext treeContext, SeaGlassContext cellContext,
    Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, Rectangle rowBounds, TreePath path, int row, boolean isExpanded,
    boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null && dropLocation.getChildIndex() == -1 && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(cellContext, ColorType.FOCUS));
    }
    SeaGlassLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g, rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g, rowBounds.x, rowBounds.y, rowBounds.width, rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    } else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(tree, path.getLastPathComponent(), selected, isExpanded, isLeaf, row,
        (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y, bounds.width, bounds.height, true);
}
 
Example 8
Source File: SynthTreeUI.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 9
Source File: SynthTreeUI.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 10
Source File: SynthTreeUI.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 11
Source File: SynthTreeUI.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 12
Source File: SynthTreeUI.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 13
Source File: SynthTreeUI.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 14
Source File: SynthTreeUI.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 15
Source File: SynthTreeUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 16
Source File: SynthTreeUI.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 17
Source File: SynthTreeUI.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 18
Source File: SynthTreeUI.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 19
Source File: SynthTreeUI.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}
 
Example 20
Source File: SynthTreeUI.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private void paintRow(TreeCellRenderer renderer,
           DefaultTreeCellRenderer dtcr, SynthContext treeContext,
           SynthContext cellContext, Graphics g, Rectangle clipBounds,
           Insets insets, Rectangle bounds, Rectangle rowBounds,
           TreePath path, int row, boolean isExpanded,
           boolean hasBeenExpanded, boolean isLeaf) {
    // Don't paint the renderer if editing this row.
    boolean selected = tree.isRowSelected(row);

    JTree.DropLocation dropLocation = tree.getDropLocation();
    boolean isDrop = dropLocation != null
                     && dropLocation.getChildIndex() == -1
                     && path == dropLocation.getPath();

    int state = ENABLED;
    if (selected || isDrop) {
        state |= SELECTED;
    }

    if (tree.isFocusOwner() && row == getLeadSelectionRow()) {
        state |= FOCUSED;
    }

    cellContext.setComponentState(state);

    if (dtcr != null && (dtcr.getBorderSelectionColor() instanceof
                         UIResource)) {
        dtcr.setBorderSelectionColor(style.getColor(
                                         cellContext, ColorType.FOCUS));
    }
    SynthLookAndFeel.updateSubregion(cellContext, g, rowBounds);
    cellContext.getPainter().paintTreeCellBackground(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    cellContext.getPainter().paintTreeCellBorder(cellContext, g,
                rowBounds.x, rowBounds.y, rowBounds.width,
                rowBounds.height);
    if (editingComponent != null && editingRow == row) {
        return;
    }

    int leadIndex;

    if (tree.hasFocus()) {
        leadIndex = getLeadSelectionRow();
    }
    else {
        leadIndex = -1;
    }

    Component component = renderer.getTreeCellRendererComponent(
                     tree, path.getLastPathComponent(),
                     selected, isExpanded, isLeaf, row,
                     (leadIndex == row));

    rendererPane.paintComponent(g, component, tree, bounds.x, bounds.y,
                                bounds.width, bounds.height, true);
}