Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Canvas replace

    I need to replace one Canvas by another. I suppose it should be:
    Code:
    public static void replaceCanvas(Canvas oldCanvas, Canvas newCanvas){
      oldCanvas = newCanvas;
    }
    Maybe I don't understand something?
    The solution for me is:
    Code:
    public static void replaceCanvas(Canvas oldCanvas, Canvas newCanvas){	
      Layout parent = (Layout) oldCanvas.getParentElement();
      Canvas[] children = parent.getMembers();
        //another challenge - get position of member
      int pos = getPos(parent, oldCanvas);
      children[pos].destroy();
      children[pos] = newCanvas;
      parent.setMembers(children);
      parent.redraw();
    }
    But I sure there is better way to do it...
    Last edited by lorez; 16 Nov 2009, 22:57.
Working...
X