當前位置: 首頁>>代碼示例>>Java>>正文


Java LookAndFeel.getDisabledIcon方法代碼示例

本文整理匯總了Java中javax.swing.LookAndFeel.getDisabledIcon方法的典型用法代碼示例。如果您正苦於以下問題:Java LookAndFeel.getDisabledIcon方法的具體用法?Java LookAndFeel.getDisabledIcon怎麽用?Java LookAndFeel.getDisabledIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.LookAndFeel的用法示例。


在下文中一共展示了LookAndFeel.getDisabledIcon方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTreeCellRendererComponent

import javax.swing.LookAndFeel; //導入方法依賴的package包/類
/**
  * 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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:71,代碼來源:DefaultTreeCellRenderer.java

示例2: getTreeCellRendererComponent

import javax.swing.LookAndFeel; //導入方法依賴的package包/類
/**
 * Configures the renderer based on the passed in components. The value is
 * set from messaging the {@link JTree} with
 * {@link JTree#convertValueToText}, which ultimately invokes
 * {@link Object#toString()} on {@code value}. The foreground {@link Color}
 * is set based on the selection and the {@link Icon} is set based on the
 * {@code leaf} and {@code expanded} parameters.
 */
@Override
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 = UIManager.getColor("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;
}
 
開發者ID:DigitalMediaServer,項目名稱:DigitalMediaServer,代碼行數:67,代碼來源:RepaintableTreeCellRenderer.java

示例3: getTreeCellRendererComponent

import javax.swing.LookAndFeel; //導入方法依賴的package包/類
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                                  final boolean sel,
                                                  boolean expanded,
                                                  boolean leaf, int row,
                                                  boolean hasFocus) {
        String stringValue = tree.convertValueToText(value, sel,
                                          expanded, leaf, row, hasFocus);
        setComponentOrientation(tree.getComponentOrientation());
        
        this.tree = tree;
        this.hasFocus = hasFocus;
        setTextAdAPI(stringValue);
//        JTree.DropLocation dropLocation = tree.getDropLocation();
//        if (dropLocation != null
//                && dropLocation.getChildIndex() == -1
//                && tree.getRowForPath(dropLocation.getPath()) == row) {
//
//            isDropCell = true;

        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);
            
    		Color fg = null;
    		if (sel) {
                fg = getTextSelectionColor();
            } else {
                fg = getTextNonSelectionColor();
            }
            super.setForeground(fg);
            setIcon(icon);
        }

        selected = sel;

        return this;
    }
 
開發者ID:javalovercn,項目名稱:j2se_for_android,代碼行數:52,代碼來源:DefaultTreeCellRenderer.java

示例4: getTreeCellRendererComponent

import javax.swing.LookAndFeel; //導入方法依賴的package包/類
/**
 * 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.
 */
@Override
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;
    isDropCell = false;

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

        Color col = UIManager.getColor("Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

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

    setForeground(fg);

    Icon icon;
    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;
}
 
開發者ID:JCheckboxTree,項目名稱:JCheckboxTree,代碼行數:71,代碼來源:CustomDefaultTreeCellRenderer.java


注:本文中的javax.swing.LookAndFeel.getDisabledIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。