本文整理汇总了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;
}
示例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");
}
示例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");
}
示例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);
}
示例5: isHighlighted
import org.jdesktop.swingx.decorator.ComponentAdapter; //导入方法依赖的package包/类
@Override
public boolean isHighlighted(Component renderer,
ComponentAdapter adapter) {
return adapter.isSelected();
}