javax.swing.tree.TreeCellRenderer Java Examples
The following examples show how to use
javax.swing.tree.TreeCellRenderer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FirstRowCellEditor.java From ramus with GNU General Public License v3.0 | 6 votes |
public boolean isCellEditable(final EventObject anEvent) { if (anEvent instanceof MouseEvent) { final MouseEvent event = (MouseEvent) anEvent; final int row = treeTable.rowAtPoint(event.getPoint()); final Rectangle bounds = tree.getRowBounds(row); int offset = bounds.x; final Object node = tree.getPathForRow(row).getLastPathComponent(); final boolean leaf = tree.getModel().isLeaf(node); final boolean expanded = tree.isExpanded(row); final TreeCellRenderer tcr = tree.getCellRenderer(); final Component treeComponent = tcr.getTreeCellRendererComponent( tree, node, true, expanded, leaf, row, false); if (treeComponent instanceof JLabel) { final JLabel label = (JLabel) treeComponent; final Icon icon = label.getIcon(); if (icon != null) { offset += icon.getIconWidth() + label.getIconTextGap(); } } if (event.getPoint().x < offset) return false; } return deligate.isCellEditable(anEvent); }
Example #2
Source File: ResultTreeView.java From netbeans with Apache License 2.0 | 6 votes |
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { boolean isResultRootNode = (value instanceof TreeNode) && (((TreeNode) value).getParent() == null); // render no icon space an empty icon of a callStackFrame boolean isCallstackFrame = false; if (null != value) { isCallstackFrame = (Visualizer.findNode(value) instanceof CallstackFrameNode); } TreeCellRenderer renderer = (isResultRootNode || isCallstackFrame) ? noIconTreeCellRenderer : defaultTreeCellRenderer; return renderer.getTreeCellRendererComponent( tree, value, selected, expanded, leaf, row, hasFocus); }
Example #3
Source File: AnalyzeSizeToolWindowTest.java From size-analyzer with Apache License 2.0 | 6 votes |
@Test public void categoryNodesHaveCorrectExtraInformation() { JPanel toolPanel = toolWindow.getContent(); Component[] components = toolPanel.getComponents(); OnePixelSplitter splitter = (OnePixelSplitter) components[0]; JBScrollPane leftPane = (JBScrollPane) splitter.getFirstComponent(); JViewport leftView = leftPane.getViewport(); Tree suggestionTree = (Tree) leftView.getView(); TreePath webPPath = getTreePathWithString(suggestionTree, webPCategoryData.toString()); TreeCellRenderer treeCellRenderer = suggestionTree.getCellRenderer(); Component renderedNode = treeCellRenderer.getTreeCellRendererComponent( suggestionTree, webPPath.getLastPathComponent(), false, false, false, suggestionTree.getRowForPath(webPPath), false); assertThat(renderedNode.toString()).contains("2 recommendations"); assertThat(renderedNode.toString()).contains("29.30 KB"); }
Example #4
Source File: SynthTreeUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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)); } } }
Example #5
Source File: GTreeDragNDropAdapter.java From ghidra with Apache License 2.0 | 5 votes |
/** Paint each of the given nodes that is inside of the clips */ private void paintNodes(List<GTreeNode> nodes, Graphics g) { TreeCellRenderer cellRenderer = tree.getCellRenderer(); Rectangle clip = g.getClipBounds(); Container parent = tree.getParent(); int yOffset = 0; try { for (GTreeNode node : nodes) { int row = tree.getRowForPath(node.getTreePath()); Rectangle rowBounds = tree.getRowBounds(row); rowBounds = SwingUtilities.convertRectangle(tree, rowBounds, parent); if (clip.y > rowBounds.y + rowBounds.height) { continue; // above our clip } if (clip.y + clip.height < rowBounds.y + rowBounds.height) { // painted past the bounds of our clip return; } Component renderer = cellRenderer.getTreeCellRendererComponent(tree, node, true, true, node.isLeaf(), row, false); renderer.setSize(renderer.getPreferredSize()); // move down the point in our graphics space into which we will paint yOffset += rowBounds.height; g.translate(0, rowBounds.height); renderer.paint(g); } } finally { // restore the point into graphics that we will paint g.translate(0, -yOffset); } }
Example #6
Source File: SynthTreeUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected TreeCellEditor createDefaultCellEditor() { TreeCellRenderer renderer = tree.getCellRenderer(); DefaultTreeCellEditor editor; if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) { editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer) renderer); } else { editor = new SynthTreeCellEditor(tree, null); } return editor; }
Example #7
Source File: CheckTreeCellRenderer.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
public CheckTreeCellRenderer(TreeCellRenderer delegate, CheckTreeSelectionModel selectionModel) { this.delegate = delegate; this.selectionModel = selectionModel; setLayout(new BorderLayout()); setOpaque(false); checkBox.setOpaque(false); }
Example #8
Source File: BindingCustomizer.java From netbeans with Apache License 2.0 | 5 votes |
private void initExpressionCombo() { TreeCellRenderer renderer = new TreeComboRenderer(FormUtils.getBundleString("MSG_BindingCustomizer_NullExpression")); // NOI18N expressionCombo = new ComboBoxWithTree(expressionModel, renderer, new Converter(expressionModel)); expressionCombo.setSelectedItem("null"); // NOI18N renderer = new TreeComboRenderer(FormUtils.getBundleString("MSG_BindingCustomizer_NullDisplayExpression")); // NOI18N displayExpressionCombo = new ComboBoxWithTree(displayExpressionModel, renderer, new Converter(displayExpressionModel)); displayExpressionCombo.setSelectedItem("null"); // NOI18N }
Example #9
Source File: SynthTreeUI.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
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)); } } }
Example #10
Source File: SynthTreeUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected TreeCellEditor createDefaultCellEditor() { TreeCellRenderer renderer = tree.getCellRenderer(); DefaultTreeCellEditor editor; if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) { editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer) renderer); } else { editor = new SynthTreeCellEditor(tree, null); } return editor; }
Example #11
Source File: SynthTreeUI.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected TreeCellEditor createDefaultCellEditor() { TreeCellRenderer renderer = tree.getCellRenderer(); DefaultTreeCellEditor editor; if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) { editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer) renderer); } else { editor = new SynthTreeCellEditor(tree, null); } return editor; }
Example #12
Source File: DarkUIUtil.java From darklaf with MIT License | 5 votes |
public static boolean isInCell(final Component c) { if (getParentOfType(DarkTableHeaderRendererPane.class, c, CELL_SEARCH_DEPTH) != null) return false; boolean inCellRenderer = getParentOfType(c, CELL_SEARCH_DEPTH, CellRendererPane.class, CellEditor.class, TableCellRenderer.class, TableCellEditor.class, TreeCellRenderer.class, TreeCellEditor.class, ListCellRenderer.class, CellRenderer.class) != null; return inCellRenderer && getParentOfType(JComboBox.class, c) == null; }
Example #13
Source File: SynthTreeUI.java From Bytecoder with Apache License 2.0 | 5 votes |
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)); } } }
Example #14
Source File: StructureTreeView.java From netbeans with Apache License 2.0 | 5 votes |
public StructureTreeView(TreeCellRenderer r,String lineStyle){ super(); tree.setCellRenderer(r); tree.putClientProperty("JTree.lineStyle", lineStyle); // NOI18N tree.setShowsRootHandles(false); //expandAll(); }
Example #15
Source File: SynthTreeUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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)); } } }
Example #16
Source File: SynthTreeUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected TreeCellEditor createDefaultCellEditor() { TreeCellRenderer renderer = tree.getCellRenderer(); DefaultTreeCellEditor editor; if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) { editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer) renderer); } else { editor = new SynthTreeCellEditor(tree, null); } return editor; }
Example #17
Source File: SynthTreeUI.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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)); } } }
Example #18
Source File: DocumentViewPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a cell renderer for the tree view. * * @param delegate delegating/original tree renderer. * @return call renderer for the tree view. */ private TreeCellRenderer createTreeCellRenderer(final TreeCellRenderer delegate) { return new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { return delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); } }; }
Example #19
Source File: SynthTreeUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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)); } } }
Example #20
Source File: SynthTreeUI.java From JDKSourceCode1.8 with MIT License | 5 votes |
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)); } } }
Example #21
Source File: JTreeOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Maps {@code JTree.getCellRenderer()} through queue */ public TreeCellRenderer getCellRenderer() { return (runMapping(new MapAction<TreeCellRenderer>("getCellRenderer") { @Override public TreeCellRenderer map() { return ((JTree) getSource()).getCellRenderer(); } })); }
Example #22
Source File: DomPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a cell renderer for the DOM tree. * * @param delegate delegating/original tree renderer. * @return call renderer for the DOM tree. */ private TreeCellRenderer createTreeCellRenderer(final TreeCellRenderer delegate) { Color origColor = UIManager.getColor("Tree.selectionBackground"); // NOI18N Color color = origColor.brighter().brighter(); if (color.equals(Color.WHITE)) { // Issue 217127 color = origColor.darker(); } // Color used for hovering highlight final Color hoverColor = color; final boolean nimbus = "Nimbus".equals(UIManager.getLookAndFeel().getID()); // NOI18N final JPanel nimbusPanel = nimbus ? new JPanel(new BorderLayout()) : null; return new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { JComponent component; if (!selected && isHighlighted(value)) { component = (JComponent)delegate.getTreeCellRendererComponent(tree, value, true, expanded, leaf, row, hasFocus); if (nimbus) { nimbusPanel.removeAll(); nimbusPanel.add(component); component = nimbusPanel; } component.setBackground(hoverColor); component.setOpaque(true); } else { component = (JLabel)delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); } return component; } }; }
Example #23
Source File: SynthTreeUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected TreeCellEditor createDefaultCellEditor() { TreeCellRenderer renderer = tree.getCellRenderer(); DefaultTreeCellEditor editor; if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) { editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer) renderer); } else { editor = new SynthTreeCellEditor(tree, null); } return editor; }
Example #24
Source File: TreeTableComboBoxCellEditor.java From aion-germany with GNU General Public License v3.0 | 5 votes |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int r, int c) { Component component = super.getTableCellEditorComponent(table, value, isSelected, r, c); //boolean rv = t.isRootVisible(); //int offsetRow = rv ? r : r - 1; int offsetRow = r; Rectangle bounds = this.table.getCellRect(offsetRow, 0, false); int offset = bounds.x; TreeCellRenderer tcr = this.table.getTreeCellRenderer(); System.out.println("Renderer is a : "+tcr); if(tcr instanceof DelegatingRenderer) tcr = ((DelegatingRenderer)tcr).getDelegateRenderer(); System.out.println("After un-delegataion, renderer is a : "+tcr); if (tcr instanceof DefaultTreeCellRenderer) { System.out.println("Renderer is a DefaultTreeCellRenderer"); Object node = this.table.getPathForRow(offsetRow).getLastPathComponent(); int depth = this.table.getPathForRow(offsetRow).getPathCount(); System.out.println("Node's depth is "+depth); offset += (depth - 1) * 20; Icon icon; if (this.table.getTreeTableModel().isLeaf(node)) icon = ((DefaultTreeCellRenderer) tcr).getLeafIcon(); else if (this.table.isExpanded(offsetRow)) icon = ((DefaultTreeCellRenderer) tcr).getOpenIcon(); else icon = ((DefaultTreeCellRenderer) tcr).getClosedIcon(); if (icon != null) { offset += ((DefaultTreeCellRenderer) tcr).getIconTextGap() + icon.getIconWidth(); } } ((PartTypeComboBox) getComponent()).offset = offset; ((PartTypeComboBox) getComponent()).setSelectedItem(value); return component; }
Example #25
Source File: RTree.java From marathonv5 with Apache License 2.0 | 5 votes |
private String getTextForNodeObject(JTree tree, Object lastPathComponent) { TreeCellRenderer renderer = tree.getCellRenderer(); if (renderer == null) { return null; } Component c = renderer.getTreeCellRendererComponent(tree, lastPathComponent, false, false, false, 0, false); if (c != null && c instanceof JLabel) { return ((JLabel) c).getText(); } return lastPathComponent.toString(); }
Example #26
Source File: SynthTreeUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected TreeCellEditor createDefaultCellEditor() { TreeCellRenderer renderer = tree.getCellRenderer(); DefaultTreeCellEditor editor; if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) { editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer) renderer); } else { editor = new SynthTreeCellEditor(tree, null); } return editor; }
Example #27
Source File: JTreeNodeJavaElement.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Component getRendererComponent(JTree tree, int row) { TreeCellRenderer cellRenderer = tree.getCellRenderer(); TreePath pathForRow = tree.getPathForRow(row); Object lastPathComponent = pathForRow.getLastPathComponent(); Component rendererComponent = cellRenderer.getTreeCellRendererComponent(tree, lastPathComponent, false, false, false, row, false); if (rendererComponent == null) { return null; } if (rendererComponent instanceof JComponent) { ((JComponent) rendererComponent).putClientProperty("jtree", (JTree) tree); ((JComponent) rendererComponent).putClientProperty("row", row); } return rendererComponent; }
Example #28
Source File: SynthTreeUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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)); } } }
Example #29
Source File: JTreeNodeJavaElement.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public Component getPseudoComponent() { return EventQueueWait.exec(new Callable<Component>() { @Override public Component call() throws Exception { validateRow(); JTree tree = (JTree) parent.getComponent(); TreeCellRenderer cellRenderer = tree.getCellRenderer(); TreePath pathForRow = tree.getPathForRow(viewRow); Object lastPathComponent = pathForRow.getLastPathComponent(); return cellRenderer.getTreeCellRendererComponent(tree, lastPathComponent, false, false, false, viewRow, false); } }); }
Example #30
Source File: JTreeJavaElement.java From marathonv5 with Apache License 2.0 | 5 votes |
private String getTextForNodeObject(JTree tree, Object lastPathComponent) { TreeCellRenderer renderer = tree.getCellRenderer(); if (renderer == null) { return null; } Component c = renderer.getTreeCellRendererComponent(tree, lastPathComponent, false, false, false, 0, false); if (c != null && c instanceof JLabel) { return ((JLabel) c).getText(); } return lastPathComponent.toString(); }