Java Code Examples for javax.swing.JTree#isEnabled()

The following examples show how to use javax.swing.JTree#isEnabled() . 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: DefaultTreeCellRenderer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 2
Source File: DefaultTreeCellRenderer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 3
Source File: DefaultTreeCellRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 4
Source File: DefaultTreeCellRenderer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 5
Source File: DefaultTreeCellRenderer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 6
Source File: DefaultTreeCellRenderer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 7
Source File: DefaultTreeCellRenderer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 8
Source File: DefaultTreeCellRenderer.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 9
Source File: DefaultTreeCellRenderer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 10
Source File: DefaultTreeCellRenderer.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 11
Source File: DefaultTreeCellRenderer.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 12
Source File: DefaultTreeCellRenderer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 13
Source File: DefaultTreeCellRenderer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 14
Source File: DefaultTreeCellRenderer.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 15
Source File: DefaultTreeCellRenderer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 16
Source File: DefaultTreeCellRenderer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
Example 17
Source File: DefaultTreeCellRenderer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}