Problem with JTree custom renderer when editing

I have a JTree which uses a custom renderer to display my own icons for different types of nodes. The problem I am having is when I setEditable to true and then attept to edit a node the icon switches back to the default icon, as soon as I am done editing it goes back.
What I am doing wrong?

Here is my rendererer
public class DeviceTreeRenderer extends DefaultTreeCellRenderer implements GuiConstants {
   public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
      JLabel returnValue = (JLabel)super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
      if (value != null) {
         returnValue.setToolTipText(value.toString());
      if (value instanceof Device) {
         returnValue.setIcon(TREE_DEVICE);
         if (!((Device)value).isAlive()) {
            returnValue.setEnabled(false);
      else if (value instanceof GuiPanelGroup) {
         if (expanded) {
            returnValue.setIcon(TREE_PANEL_GROUP_OPEN);
         else {
            returnValue.setIcon(TREE_PANEL_GROUP_CLOSED);
      else if (value instanceof GuiPanel && ((GuiPanel)value).isDirty()) {
         returnValue.setIcon(TREE_PANEL_DIRTY);
      return returnValue;
}Here is my editor:
public class WwpJTreeCellEditor extends DefaultTreeCellEditor implements GuiConstants {
      private WwpJTree tree;
       * Creates a new WwpJTreeCellEditor.
       * @param tree The WwpJTree to associate with this editor.
      public WwpJTreeCellEditor(WwpJTree tree) {
         super(tree, (DefaultTreeCellRenderer)tree.getCellRenderer());
         this.tree = tree;
       * Overrides the default isCellEditable so that we check the isEditable() method
       * of the WwpJTreeNodes.
       * @param e An EventObject.
      public boolean isCellEditable(EventObject e) {
         boolean returnValue = super.isCellEditable(e);
         if (returnValue) {
            WwpJTreeNode node = this.tree.getSelectedNode();
            if (node == null || !node.isEditable() || node.isDragging()) {
               returnValue = false;
         return returnValue;
   }In my JTree I make these calls:
super.setCellRenderer(new DeviceTreeRenderer());
super.setCellEditor(new WwpJTreeCellEditor(this));
super.setEditable(true);

Similar Messages

Maybe you are looking for

  • How do I use credit on my iTunes account towards purchases in an app I have?

    How do I use credit I have in my ITunes account toward purchases in an App I have?

  • Error While Viewing JNDI Tree

              Hi           I'm facing the following problem while viewing the JNDI tree. I had configured           two servers ejbServer,ejbServer1 both clustered, i can able to start both the           servers, but in the JNDI tree when i click ejbServ

  • Imac Intel - Sleeping display (only imac screen )

    I Get a Imac 2008 Alu , And I use it like a media center with a videoprojector ( videoprojector is the second screen) All works well , but As the Imac Screen is very very Bright , I want to Sleep the display of the Imac , but get the Second display O

  • How to Change Date Format according to the Locale/Country of Portal User

    Hi, In a webdynpro applicaiton, how to chage the  Date Format according to the Locale/Country of Portal User. Consider for INDIA: mm/dd/yyyy Consider for UK: yyyy/mm/dd So when i select the date from the Date Picker[input ui element bound to date con

  • To remove a cube

    Hi guys, The requirement is to analyze the removal of a cube (an overview cube), can u guys tell me the precaution and steps to take like archival, performance if any and the functions this is doin has to be replaced by detail cube. thanks, your help