Re: TreeCellEditor and TreeCellRenderer



On 6 Temmuz, 19:47, Jason Cavett <jason.cav...@xxxxxxxxx> wrote:
I'm a little confused about the differences between a CellEditor and a
CellRenderer (specifically the "Tree" version). From my
understanding, the renderer is HOW the icons are displayed and the
editor is how to edit the fields. It seems other people have this
same idea from my searches in Google.

If this is right, what I am confused about is why a
DefaultTreeCellEditor takes a DefaultTreeCellRenderer as part of its
constructor? Is this so icons can be rendered even when editing?

The reason I ask is I have created my own TreeCellEditor and my own
TreeCellRenderer by subclassing DefaultTreeCellEditor and
DefaultTreeCellRenderer, respectively. Within my renderer, I wrote
the logic so that the icons would be set to icons I wanted (based on
the current state of a node in the tree since I have different states
other than open/close). Within my editor I override
determineOffset(...) so that I can keep the current active Icon and
don't get the default folder/bullet icons. I also implement
CellEditorListener so I can tell when a person starts/stops editing
the tree node name.

Am I approaching this correctly? Thanks for any feedback.

Hi, I am also confused with the idea but I have an opinion,
Actually the renderer part only for display, it takes your specific
(BookInfo)class variables and displayes them where you want, this info
comes into the JTree at the construction. And the editor, is the
reverse operation, when you edit some thing it recognize and fires
some events, at this part it uses "public Object getCellEditorValue
()" in order to create new instances from your inputs for example;


public Object getCellEditorValue ()
{
JTextField textField = renderer.getRenderer ();
OntologyNode node = new OntologyNode (); //MY INFO
node.setValue (textField.getText ());
node.setValue (textField.getText ());
return node;
}

so that when your editing finished it calls this method.

I think you work only for icons, but there can be done anything with
the idea, you can displaye you usercontrols in JTree and also edit
them.


.



Relevant Pages

  • Re: Name change
    ... and re-sizable and over-lapping windows ... ... On a 640x480 9" display with a mind-boggling 16 shades of grey, ... launcher, ... (application icons displayed on the dock often display information). ...
    (uk.people.support.depression)
  • Re: My icons are not displayed properly in my DVD-RW optical drive
    ... This is a bug in Windows that will never be fixed, ... This behaviour happens when 'use large icons' is checked under 'Display Properties'> 'Effects...'. ... icons are displayed correctly in all other drives of my computer. ...
    (microsoft.public.windowsxp.general)
  • Re: A Suggestion For Higher-Quality Open-Source Software
    ... I'm guessing that, since gimp uses it, it's some ... in the current directory display to be rendered somehow. ... or simple icons. ... Take note that Linux is not a GUI operating system. ...
    (comp.os.linux.misc)
  • Re: Wince 4.2 to wince 5.0 display driver migration
    ... I've just seen this on a third party windows ce 5.0 hardware, ... 480*320 VGA type display. ... firstly the spacing of icons changed from ce 4.2 to 5.0 as far as QVGA ... graphics controller and the driver that they supplied. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: My entire monitor display shrunk to half its size
    ... Changing the resolution won't change the size of anything unless the display is "stretching" a lower resolution to fill the screen. ... When you changed the desktop to 1024x768, that gave you more desktop on which to place icons, but the size of the icons themselves hasn't changed ... ... Things that could have changed include font sizes, icon sizes, the global Windows display DPI setting and the "theme" used by Windows. ... All of these can be changed, but the chances of finding the exact combination of all of the settings that you had before are not good. ...
    (comp.sys.laptops)