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)
  • [opensuse] Groking KDE4
    ... I guess I have to be added to the class of users who have failed to grok the new KDE4 user interface.. ... I got no idea why it decides what set of items to display, are or are not appropriate, but it seems to be related to the particular "desktop" that I am on. ... Sometimes, and again I do not understand the context of what drives this, a menu also pops up in this "zoom" display and it has an additional item that I had not previously discovered - "Add Activity" And I repeat, sometimes this menu does not pop up and I have no idea how to reach it other than to zoom in on one of the "Activities"/"Desktops" and then use the upper right button to zoom out until this sequence gives me this particular menu. ... Also the display of desktop icons or the desktop folder seems to move around from one desktop to another. ...
    (SuSE)
  • 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)