本文整理汇总了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"));
}
}
示例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"));
}
}
示例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);
}
}
示例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"));
}
}
示例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);
}
}
示例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"));
}
}
示例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"));
}
}
示例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);
}
示例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"));
}
}
示例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"));
}
}
示例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));
}
}
}
示例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());
}
}
示例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;
}
示例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));
}
}
}
示例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;
}