当前位置: 首页>>代码示例>>Java>>正文


Java ComponentAdapter.isSelected方法代码示例

本文整理汇总了Java中org.jdesktop.swingx.decorator.ComponentAdapter.isSelected方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentAdapter.isSelected方法的具体用法?Java ComponentAdapter.isSelected怎么用?Java ComponentAdapter.isSelected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdesktop.swingx.decorator.ComponentAdapter的用法示例。


在下文中一共展示了ComponentAdapter.isSelected方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyRenderer

import org.jdesktop.swingx.decorator.ComponentAdapter; //导入方法依赖的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

示例2: interactiveColorValueMappedHighlighter

import org.jdesktop.swingx.decorator.ComponentAdapter; //导入方法依赖的package包/类
/**
 * Example to highlight against a value/color map. <p>
 * Here the Highlighter takes full control. Which is a bit 
 * on the border line of 
 * the intended distribution of responsibility between
 * Highlighter and HighlighterPredicate.
 */
public void interactiveColorValueMappedHighlighter() {
    JXTable table = new JXTable(new AncientSwingTeam());
    // build a quick color lookup to simulate multi-value value-based
    // coloring
    final int numberColumn = 3;
    table.toggleSortOrder(numberColumn);
    final Map<Integer, Color> lookup = new HashMap<Integer, Color>();
    Color[] colors = new Color[] { Color.YELLOW, Color.CYAN, Color.MAGENTA,
            Color.GREEN };
    int rowsPerColor = (table.getRowCount() - 5) / colors.length;
    for (int i = 0; i < colors.length; i++) {
        for (int j = 0; j < rowsPerColor; j++) {
            lookup.put((Integer) table.getValueAt(i * rowsPerColor + j,
                    numberColumn), colors[i]);
        }
    }
    table.resetSortOrder();
    // PENDING JW: add and use HighlightPredicate.SELECTED/UN_SELECTED 
    Highlighter hl = new ColorHighlighter() {

        @Override
        protected void applyBackground(Component renderer, ComponentAdapter adapter) {
            if (adapter.isSelected()) return;
            Color background = lookup.get(adapter.getValue(numberColumn));
            if (background != null) {
                renderer.setBackground(background);
            }
        }
    };
    table.addHighlighter(hl);
    showWithScrollingInFrame(table,
            "conditional highlighter with value-based color mapping");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:41,代码来源:HighlighterClientVisualCheck.java

示例3: interactiveDynamicCellHeightTree

import org.jdesktop.swingx.decorator.ComponentAdapter; //导入方法依赖的package包/类
public void interactiveDynamicCellHeightTree() {
      final JXTree tree = new  JXTree(AncientSwingTeam.createNamedColorTreeModel());
      
      TreeSelectionListener l = new TreeSelectionListener() {
          
          @Override
          public void valueChanged(TreeSelectionEvent e) {
              LOG.info("height " + tree.getRowHeight());
//              tree.setRowHeight(-1);
              SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      tree.invalidateCellSizeCache();
                  }
              });
              
          }
          
      };
      tree.addTreeSelectionListener(l);
      tree.setCellRenderer(new DefaultTreeRenderer());
//      tree.setLargeModel(true);
      tree.setRowHeight(0);
      HighlightPredicate selected = new HighlightPredicate() {
          
          @Override
          public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
              return adapter.isSelected();
          }
      };
      Highlighter hl = new FontHighlighter(selected, tree.getFont().deriveFont(50f));
      tree.addHighlighter(hl);
      showWithScrollingInFrame(tree, "big font on focus");
  }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:34,代码来源:JXTreeVisualCheck.java

示例4: applyBackground

import org.jdesktop.swingx.decorator.ComponentAdapter; //导入方法依赖的package包/类
@Override
protected void applyBackground(Component renderer, ComponentAdapter adapter) {
	if (!adapter.isSelected()) {
		Color ok, error, disabled;
		if (adapter.getDepth() == 1) {
			ok = new Color(157, 204, 88);
			error = new Color(204, 0, 20);
			disabled = Color.darkGray;
		} else {
			ok = new Color(208, 217, 146);
			error = new Color(230, 80, 70);
			disabled = Color.lightGray;
		}
		Object value = adapter.getValue(PluginInformationPane.UID_INDEX);
		if (value instanceof String) {
			String uid = (String) value;
			if (PluginManager.getInstance().isActive(uid) && PluginManager.getInstance().isCurrentlyEnabled(uid)) {
				renderer.setBackground(ok);
			} else if (!PluginManager.getInstance().isCurrentlyEnabled(uid)) {
				renderer.setBackground(disabled);
			} else if (!PluginManager.getInstance().isActive(uid)) {
				renderer.setBackground(error);
			}
		}
	}
	super.applyBackground(renderer, adapter);
}
 
开发者ID:sing-group,项目名称:aibench-project,代码行数:28,代码来源:PluginInformationPane.java

示例5: isHighlighted

import org.jdesktop.swingx.decorator.ComponentAdapter; //导入方法依赖的package包/类
@Override
public boolean isHighlighted(Component renderer,
        ComponentAdapter adapter) {
    return adapter.isSelected();
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:6,代码来源:MonthViewExtDemoUtils.java


注:本文中的org.jdesktop.swingx.decorator.ComponentAdapter.isSelected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。