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


Java DefaultTreeCellRenderer.setBackgroundSelectionColor方法代碼示例

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


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

示例1: updateUI

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

示例2: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
 * 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.
    final TreeCellRenderer tcr = getCellRenderer();
    if (tcr instanceof DefaultTreeCellRenderer) {
        final DefaultTreeCellRenderer renderer = (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.
        // renderer.setBorderSelectionColor(null);
        renderer.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
        renderer.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
    }
}
 
開發者ID:rnveach,項目名稱:checkstyle-backport-jre6,代碼行數:21,代碼來源:TreeTableCellRenderer.java

示例3: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
 * updateUI is overridden to set the colors of the Tree's renderer to
 * match that of the table.
 */
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"));
		((DefaultTreeCellRenderer)this.getCellRenderer()).setLeafIcon(null);
		((DefaultTreeCellRenderer)this.getCellRenderer()).setOpenIcon(null);
		((DefaultTreeCellRenderer)this.getCellRenderer()).setClosedIcon(null);
	}
}
 
開發者ID:cst316,項目名稱:spring16project-Modula-2,代碼行數:25,代碼來源:JTreeTable.java

示例4: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
     * updateUI is overridden to set the colors of the Tree's renderer to
     * match that of the table.
     */
    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);
 
dtcr.setBorderSelectionColor(null);
            dtcr.setTextSelectionColor(UIManager
                    .getColor("Table.selectionForeground"));
            dtcr.setBackgroundSelectionColor(UIManager
                    .getColor("Table.selectionBackground"));
        }
    }
 
開發者ID:cst316,項目名稱:spring16project-Modula-2,代碼行數:21,代碼來源:TaskTable.java

示例5: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
 * 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"));
		((DefaultTreeCellRenderer) this.getCellRenderer()).setLeafIcon(null);
		((DefaultTreeCellRenderer) this.getCellRenderer()).setOpenIcon(null);
		((DefaultTreeCellRenderer) this.getCellRenderer()).setClosedIcon(null);
	}
}
 
開發者ID:cst316,項目名稱:spring16project-Fortran,代碼行數:24,代碼來源:JTreeTable.java

示例6: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
 * 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);

		dtcr.setBorderSelectionColor(null);
		dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
		dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
	}
}
 
開發者ID:cst316,項目名稱:spring16project-Fortran,代碼行數:20,代碼來源:TaskTable.java

示例7: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
 * 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.
    // TODO JW: need to revisit...
    // a) the "real" of a JXTree is always wrapped into a DelegatingRenderer
    //  consequently the if-block never executes
    // b) even if it does it probably (?) should not 
    // unconditionally overwrite custom selection colors. 
    // Check for UIResources instead. 
    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"));
    }
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:28,代碼來源:JXTreeTable.java

示例8: interactiveCoreRendererCustomColor

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
 * Custom renderer colors of core DefaultTreeCellRenderer not respected.
 * This is intentional: treeTable's highlighters must rule, so the
 * renderer colors are used to force the treecellrenderer to use the 
 * correct values.
 */
public void interactiveCoreRendererCustomColor() {
    JXTreeTable treeTable = new JXTreeTable(new FileSystemModel());
    treeTable.addHighlighter(HighlighterFactory.createSimpleStriping());
    DefaultTreeCellRenderer legacy = createBackgroundTreeRenderer();
    // in a treetable this has no effect: treetable.applyRenderer 
    // internally resets them to the same colors as tree itself
    // (configured by the table's highlighters
    legacy.setBackgroundNonSelectionColor(Color.YELLOW);
    legacy.setBackgroundSelectionColor(Color.RED);
    treeTable.setTreeCellRenderer(legacy);
    JTree tree = new JXTree(treeTable.getTreeTableModel());
    DefaultTreeCellRenderer other = createBackgroundTreeRenderer();
    other.setBackgroundNonSelectionColor(Color.YELLOW);
    other.setBackgroundSelectionColor(Color.RED);
    tree.setCellRenderer(other);
    JXFrame frame = wrapWithScrollingInFrame(treeTable, tree, "legacy renderers - highlight complete cell");
    frame.setVisible(true);  
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:25,代碼來源:JXTreeTableIssues.java

示例9: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
 * updateUI is overridden to set the colors of the Tree's renderer to
 * match that of the table.
 */
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"));
    }
}
 
開發者ID:dvorka,項目名稱:mindraider,代碼行數:22,代碼來源:JTreeTable.java

示例10: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
 * updateUI is overridden to set the colors of the Tree's renderer
 * to match that of the table.
 */
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"));
    }
}
 
開發者ID:hypergraphdb,項目名稱:viewer,代碼行數:22,代碼來源:JTreeTable.java

示例11: configureRenderer

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
private void configureRenderer(SynthContext context) {
    TreeCellRenderer renderer = tree.getCellRenderer();

    if (renderer instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer r = (DefaultTreeCellRenderer)renderer;
        SynthStyle style = context.getStyle();

        context.setComponentState(ENABLED | SELECTED);
        Color color = r.getTextSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setTextSelectionColor(style.getColor(
                                 context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setBackgroundSelectionColor(style.getColor(
                                    context, ColorType.TEXT_BACKGROUND));
        }

        context.setComponentState(ENABLED);
        color = r.getTextNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setTextNonSelectionColor(style.getColorForState(
                                    context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setBackgroundNonSelectionColor(style.getColorForState(
                              context, ColorType.TEXT_BACKGROUND));
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:33,代碼來源:SynthTreeUI.java

示例12: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
public void updateUI() {
  super.updateUI();
  TreeCellRenderer tcr = super.getCellRenderer();
  if (tcr instanceof DefaultTreeCellRenderer) {
    DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer)tcr;
    dtcr.setTextSelectionColor(UIUtil.getTableSelectionForeground());
    dtcr.setBackgroundSelectionColor(UIUtil.getTableSelectionBackground());
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:TreeTableTree.java

示例13: applyRenderer

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
/**
 * Performs configuration of the tree's renderer if the adapter's column is
 * the hierarchical column, does nothing otherwise.
 * <p>
 * 
 * Note: this is legacy glue if the treeCellRenderer is of type
 * DefaultTreeCellRenderer. In that case the renderer's
 * background/foreground/Non/Selection colors are set to the tree's
 * background/foreground depending on the adapter's selection state. Does
 * nothing if the treeCellRenderer is backed by a ComponentProvider.
 * 
 * @param component the rendering component
 * @param adapter component data adapter
 * @throws NullPointerException if the specified component or adapter is
 *         null
 */
protected Component applyRenderer(Component component,
        ComponentAdapter adapter) {
    if (component == null) {
        throw new IllegalArgumentException("null component");
    }
    if (adapter == null) {
        throw new IllegalArgumentException("null component data adapter");
    }

    if (isHierarchical(adapter.column)) {
        // After all decorators have been applied, make sure that relevant
        // attributes of the table cell renderer are applied to the
        // tree cell renderer before the hierarchical column is rendered!
        TreeCellRenderer tcr = renderer.getCellRenderer();
        if (tcr instanceof JXTree.DelegatingRenderer) {
            tcr = ((JXTree.DelegatingRenderer) tcr).getDelegateRenderer();

        }
        if (tcr instanceof DefaultTreeCellRenderer) {

            DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
            // this effectively overwrites the dtcr settings
            if (adapter.isSelected()) {
                dtcr.setTextSelectionColor(component.getForeground());
                dtcr.setBackgroundSelectionColor(component.getBackground());
            } else {
                dtcr.setTextNonSelectionColor(component.getForeground());
                dtcr.setBackgroundNonSelectionColor(component
                        .getBackground());
            }
        }
    }
    return component;
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:51,代碼來源:JXTreeTable.java

示例14: configureRenderer

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
private void configureRenderer(SeaGlassContext context) {
    TreeCellRenderer renderer = tree.getCellRenderer();

    if (renderer instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer r = (DefaultTreeCellRenderer) renderer;
        SeaGlassStyle style = (SeaGlassStyle)context.getStyle();

        context.setComponentState(ENABLED | SELECTED);
        Color color = r.getTextSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setTextSelectionColor(style.getColor(context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setBackgroundSelectionColor(style.getColor(context, ColorType.TEXT_BACKGROUND));
        }

        context.setComponentState(ENABLED);
        color = r.getTextNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setTextNonSelectionColor(style.getColorForState(context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setBackgroundNonSelectionColor(style.getColorForState(context, ColorType.TEXT_BACKGROUND));
        }
    }
}
 
開發者ID:khuxtable,項目名稱:seaglass,代碼行數:29,代碼來源:SeaGlassTreeUI.java

示例15: createDocPane

import javax.swing.tree.DefaultTreeCellRenderer; //導入方法依賴的package包/類
private JTree createDocPane() {
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    for (Map.Entry<?,? extends List<?>> docEntry : getDoc().getItemTree()
        .entrySet()) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(docEntry.getKey());
        root.add(node);
        for (Object rule : docEntry.getValue()) {
            node.add(new DefaultMutableTreeNode(rule));
        }
    }
    final JTree result = new JTree(root) {
        @Override
        public String getToolTipText(MouseEvent evt) {
            if (getRowForLocation(evt.getX(), evt.getY()) == -1) {
                return null;
            }
            TreePath curPath = getPathForLocation(evt.getX(), evt.getY());
            Object userObject =
                ((DefaultMutableTreeNode) curPath.getLastPathComponent()).getUserObject();
            return getToolTip(userObject);
        }
    };
    result.setRootVisible(false);
    result.setShowsRootHandles(true);
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) result.getCellRenderer();
    renderer.setBackgroundNonSelectionColor(null);
    renderer.setBackgroundSelectionColor(null);
    renderer.setTextSelectionColor(null);
    renderer.setLeafIcon(null);
    renderer.setClosedIcon(null);
    renderer.setOpenIcon(null);
    result.setCellRenderer(renderer);
    ToolTipManager.sharedInstance()
        .registerComponent(result);
    result.addMouseListener(new DismissDelayer(result));
    for (int i = 0; i < root.getChildCount(); i++) {
        result
            .expandPath(new TreePath(((DefaultMutableTreeNode) root.getChildAt(i)).getPath()));
    }
    result.setBackground(null);
    return result;
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:43,代碼來源:ControlDisplay.java


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