Questions tagged [treecellrenderer]

TreeCellRenderer is a Java Swing interface that defines the method required by any object that would like to be a renderer for cells in a JTable.

TreeCellRenderer is a Java Swing interface that defines the method required by any object that would like to be a renderer for cells in a JTable.

The interface defines only one method, getTreeCellRendererComponent, that takes the value to be rendered and various additional information (selected, focused, is a leaf, etc). The method must return an instance of Component that is positioned at the tree cell location, later calling paint() on it. It is not uncommon to derive the renderer itself from a component and return this.

49 questions
12
votes
2 answers

Set icon to each node in Jtree

I want to set for each node in my JTree a different icon, actually I'm loading each node from a data base, with a "while", I set each icon like a root, leaf or parent. Like this: All my declarations are global: private ResultSet…
Vlad
  • 190
  • 1
  • 3
  • 13
7
votes
1 answer

Change JTree row height resizing behavior when rendering

I want to use a custom TreeCellRenderer containing three text fields only when a node is SELECTED, while use the default renderer when the node is NOT SELECTED. The problem is that although I've set an appropriate preferred and minimum size for the…
4
votes
2 answers

How to set Jtree node icon dynamically

I want to display separate icon for grouped and ungrouped nodes.I created a customTreeCellRender.My sample codes given below.In for loop odd one nodes have one icon and evens have another.But not change the icon of nodes.In my application…
User123
  • 71
  • 3
  • 13
3
votes
2 answers

Change JTree icons based on custom Object states

I have a JTree, based on several custom classes. I want to give several Nodes a specific icon. Therefore i did the following code based on this link: Dynamically change icon of specific nodes in JTree DefaultTreeCellRenderer renderer = new…
user1648409
3
votes
1 answer

TreeItem selection width in a TreeView

I'm using JavaFX 8 and I'm currently doing some GUI developments. I have a little problem with my TreeView and I need your help. Do you know if it is possible, in a TreeView, to select just the label and not the whole width of the TreeCell ? I mean…
Jbprod
  • 209
  • 2
  • 7
3
votes
2 answers

JTree nodes won't get visually selected

Somehow I am not able to enable a "select highlight" for my JTree nodes. I am working with a custom cell renderer in my project (which most likely causes this problem). This is the full renderer class code: protected class ProfessionTreeCellRenderer…
spaceemotion
  • 1,140
  • 3
  • 18
  • 29
3
votes
1 answer

Changing text style of DefaultMutableTreeNode

I have created a custom JTree. That tree could be filtered to show only those nodes that contains given criteria (string). Now, is there any way to bold only that part of DefaulMutableTreeNode that contains searched string? If a tree node has label…
guest86
  • 2,706
  • 8
  • 42
  • 72
2
votes
0 answers

Yet another dynamic custom Jtree icons question

Im trying to create a Jtree using multiple individual icons (different icons for each node) i have tried multiple solutions, but any of them really did the job. a lot just changes the "leaf, isClosed, etc." options ImageIcon pointer; (INSIDE public…
Tinchouu1
  • 21
  • 1
2
votes
1 answer

Java JTree custom icon changes back to default icon while editing tree cell

In my Code I customize a DefaultTreeCellRenderer to give my nodes a custom icon. setCellRenderer(new DefaultTreeCellRenderer() { private static final long serialVersionUID = -2839238218110688876L; private ImageIcon icon =…
CodeJ
  • 23
  • 3
2
votes
1 answer

JTree Nimbus Selectionbackground not Working on Java 1.8

I've modified the JTree SelectionBackground by following this approach.It's working fine in Java 1.7.x whereas the selection is white is Java 1.8.Ref Screenshot. Is there any way to fix it. MCVE code to reproduce this problem import…
Madhan
  • 5,366
  • 4
  • 23
  • 54
2
votes
1 answer

set different jtree row heights dynamically

All, Spent last two days trying to dynamically set different row heights for a JTree but zero success. Below is an image of what I'm trying to achieve... Here's what I have tried: (1) using setRowHeight(0) so the node would query it's current cell…
Strokes
  • 25
  • 5
  • 20
2
votes
0 answers

How can set setTreeCellRenderer at JXTreeTable

I have this code to create a custom JXTreeTable and set a Custom CellRenderer. This is the code: tableCatSpese = new TableAlbero(null); public TableAlbero(List listaConti){ setTreeTableModel(new…
bircastri
  • 2,707
  • 7
  • 38
  • 96
2
votes
1 answer

How to set custom DefaultTreeCellRenderer at JXTreeTable

I want to set my custom DefaultTreeCellRenderer. So I have built this class: class CustomTreeTableSpeseXCategoriaSpese extends DefaultTreeCellRenderer { /** * */ private static final long serialVersionUID = 4842418316518803090L; …
bircastri
  • 2,707
  • 7
  • 38
  • 96
2
votes
1 answer

How do you make components of JPanel as a node in JTree usable?

When I click on the JButton nothing happens. This applies even for a JScrollPane that I put in (it shows, but will not scroll). Why is the JPanel not at the front? I get the sense that something has to be overridden. Should it be the expansion of…
Jeff
  • 43
  • 6
2
votes
1 answer

JLabel within JTree won't resize when content changes

I have a JTree that behaves like so: The root has a user object of type RootObject; it uses a plaintext label and is static throughout the lifespan of the tree. Each child has a user object of type ChildObject, which may be in one of three states:…
Jesse
  • 257
  • 1
  • 3
  • 12
1
2 3 4