public void removeLayoutComponent(Component comp, boolean force) { synchronized (comp.getTreeLock()) { if (comp == free) { // There is a bug (feature) in the SWING JLayeredPane. When a component's // layer is set using setLayer() the component is removed from it's container // and then re-added. Unfortunately it is re-added with null constraints. This // would cause the free component to become a CENTER component. To get round // this DO NOT remove a free component from the layout. if (force) { System.out.println("Removed free component " + comp); free = null; } else { // on dragging and dropping a result into annotView this message comes // with the JScrollBar which seems bizarre to me and bears looking into. // For now im just commenting out the message. // their should be a if (Debug.DEBUG) or something // System.out.println("Attempt to removed free component " + comp); } } else { // System.out.println("Removed super component " + comp); super.removeLayoutComponent(comp); } } }
/** Adds the specified component with the specified name to the layout. */ public void addLayoutComponent(String name, Component comp) { synchronized (comp.getTreeLock()) { if ("Grip".equals(name)) { // NOI18N grip = comp; } else if ("Action".equals(name)) { // NOI18N actions.addElement(comp); } else throw new IllegalArgumentException( "cannot add to layout: unknown constraint: " + name); // NOI18N } }
public void addLayoutComponent(Component component, Object constraints) { synchronized (component.getTreeLock()) { if (constraints != null && ((String) constraints).equals(NONE)) { free = component; // System.out.println("Added free component " + component); } else { if (component != free) { // System.out.println("Added super component " + component); super.addLayoutComponent(component, constraints); } else { System.out.println("Tried to readd free component " + component); } } } // System.out.println("returned from addLayoutComponent"); }
/** Removes the specified component from the layout. */ public void removeLayoutComponent(Component comp) { synchronized (comp.getTreeLock()) { if (grip == comp) grip = null; else actions.removeElement(comp); } }