@Override public void insert(Decorator decorator, int index) { if (decorator == null) { throw new IllegalArgumentException("decorator is null"); } // Repaint the the component's previous decorated region if (parent != null) { parent.repaint(getDecoratedBounds()); } decorators.insert(decorator, index); // Repaint the the component's current decorated region if (parent != null) { parent.repaint(getDecoratedBounds()); } componentDecoratorListeners.decoratorInserted(Component.this, index); }
@Override public void insert(Decorator decorator, int index) { if (decorator == null) { throw new IllegalArgumentException("decorator is null"); } // Repaint the the component's previous decorated region if (parent != null) { parent.repaint(getDecoratedBounds()); } decorators.insert(decorator, index); // Repaint the the component's current decorated region if (parent != null) { parent.repaint(getDecoratedBounds()); } componentDecoratorListeners.decoratorInserted(Component.this, index); }
@Override public Decorator update(int index, Decorator decorator) { if (decorator == null) { throw new IllegalArgumentException("decorator is null."); } // Repaint the the component's previous decorated region if (parent != null) { parent.repaint(getDecoratedBounds()); } Decorator previousDecorator = decorators.update(index, decorator); // Repaint the the component's current decorated region if (parent != null) { parent.repaint(getDecoratedBounds()); } componentDecoratorListeners.decoratorUpdated(Component.this, index, previousDecorator); return previousDecorator; }
@Override public Graphics2D prepare(Component component, Graphics2D graphics) { if (clip) { Bounds decoratedBounds = component.getDecoratedBounds(); graphics.clipRect(decoratedBounds.x - component.getX(), decoratedBounds.y - component.getY(), decoratedBounds.width, decoratedBounds.height); } graphics.translate(x, y); return graphics; }
@Override public Graphics2D prepare(Component component, Graphics2D graphics) { if (clip) { Bounds decoratedBounds = component.getDecoratedBounds(); graphics.clipRect(decoratedBounds.x - component.getX(), decoratedBounds.y - component.getY(), decoratedBounds.width, decoratedBounds.height); } graphics.translate(x, y); return graphics; }
@Override public Decorator update(int index, Decorator decorator) { if (decorator == null) { throw new IllegalArgumentException("decorator is null."); } // Repaint the the component's previous decorated region if (parent != null) { parent.repaint(getDecoratedBounds()); } Decorator previousDecorator = decorators.update(index, decorator); // Repaint the the component's current decorated region if (parent != null) { parent.repaint(getDecoratedBounds()); } componentDecoratorListeners.decoratorUpdated(Component.this, index, previousDecorator); return previousDecorator; }
@Override public Sequence<Decorator> remove(int index, int count) { if (count > 0) { // Repaint the the component's previous decorated region if (parent != null) { parent.repaint(getDecoratedBounds()); } } Sequence<Decorator> removed = decorators.remove(index, count); if (count > 0) { if (parent != null) { // Repaint the the component's current decorated region parent.repaint(getDecoratedBounds()); } componentDecoratorListeners.decoratorsRemoved(Component.this, index, removed); } return removed; }
@Override public Sequence<Decorator> remove(int index, int count) { if (count > 0) { // Repaint the the component's previous decorated region if (parent != null) { parent.repaint(getDecoratedBounds()); } } Sequence<Decorator> removed = decorators.remove(index, count); if (count > 0) { if (parent != null) { // Repaint the the component's current decorated region parent.repaint(getDecoratedBounds()); } componentDecoratorListeners.decoratorsRemoved(Component.this, index, removed); } return removed; }
parent.repaint(getDecoratedBounds()); parent.repaint(getDecoratedBounds());
parent.repaint(getDecoratedBounds()); parent.repaint(getDecoratedBounds());
parent.repaint(getDecoratedBounds()); parent.repaint(getDecoratedBounds());
parent.repaint(getDecoratedBounds()); parent.repaint(getDecoratedBounds());
@Override public void insert(Component component, int index) { assertEventDispatchThread(); if (component == null) { throw new IllegalArgumentException("component is null."); } if (component instanceof Container && ((Container)component).isAncestor(this)) { throw new IllegalArgumentException("Component already exists in ancestry."); } if (component.getParent() != null) { throw new IllegalArgumentException("Component already has a parent."); } component.setParent(Container.this); components.insert(component, index); // Repaint the area occupied by the new component repaint(component.getDecoratedBounds()); invalidate(); containerListeners.componentInserted(Container.this, index); }
@Override public void insert(Component component, int index) { assertEventDispatchThread(); if (component == null) { throw new IllegalArgumentException("component is null."); } if (component instanceof Container && ((Container)component).isAncestor(this)) { throw new IllegalArgumentException("Component already exists in ancestry."); } if (component.getParent() != null) { throw new IllegalArgumentException("Component already has a parent."); } component.setParent(Container.this); components.insert(component, index); // Repaint the area occupied by the new component repaint(component.getDecoratedBounds()); invalidate(); containerListeners.componentInserted(Container.this, index); }
parent.repaint(getDecoratedBounds()); parent.repaint(getDecoratedBounds());
parent.repaint(getDecoratedBounds()); parent.repaint(getDecoratedBounds());
/** * Moves a component within the component sequence. * * @param from * @param to */ public void move(int from, int to) { assertEventDispatchThread(); if (from != to) { int n = components.getLength(); indexBoundsCheck("from", from, 0, n - 1); indexBoundsCheck("to", to, 0, n - 1); Sequence<Component> removed = components.remove(from, 1); Component component = removed.get(0); components.insert(component, to); // Repaint the area occupied by the component repaint(component.getDecoratedBounds()); // Notify listeners containerListeners.componentMoved(this, from, to); } }
/** * Moves a component within the component sequence. * * @param from * @param to */ public void move(int from, int to) { assertEventDispatchThread(); if (from != to) { int n = components.getLength(); indexBoundsCheck("from", from, 0, n - 1); indexBoundsCheck("to", to, 0, n - 1); Sequence<Component> removed = components.remove(from, 1); Component component = removed.get(0); components.insert(component, to); // Repaint the area occupied by the component repaint(component.getDecoratedBounds()); // Notify listeners containerListeners.componentMoved(this, from, to); } }
@Override public Sequence<Component> remove(int index, int count) { assertEventDispatchThread(); Sequence<Component> removed = components.remove(index, count); // Set the removed components' parent to null and repaint the area // formerly occupied by the components for (int i = 0, n = removed.getLength(); i < n; i++) { Component component = removed.get(i); if (component == mouseOverComponent) { if (mouseOverComponent.isMouseOver()) { mouseOverComponent.mouseOut(); } mouseOverComponent = null; Mouse.setCursor(this); } repaint(component.getDecoratedBounds()); component.setParent(null); } if (removed.getLength() > 0) { invalidate(); containerListeners.componentsRemoved(Container.this, index, removed); } return removed; }
@Override public Sequence<Component> remove(int index, int count) { assertEventDispatchThread(); Sequence<Component> removed = components.remove(index, count); // Set the removed components' parent to null and repaint the area // formerly occupied by the components for (int i = 0, n = removed.getLength(); i < n; i++) { Component component = removed.get(i); if (component == mouseOverComponent) { if (mouseOverComponent.isMouseOver()) { mouseOverComponent.mouseOut(); } mouseOverComponent = null; Mouse.setCursor(this); } repaint(component.getDecoratedBounds()); component.setParent(null); } if (removed.getLength() > 0) { invalidate(); containerListeners.componentsRemoved(Container.this, index, removed); } return removed; }