/** * Sets the border for some state of the component that displays this model. Which identifiers * for <code>key</code> are actually used depends on that component. * @param key the key of the border * @param border the new border or <code>null</code> */ public void setBorder( String key, BorderModifier border ){ BorderModifier oldBorder = borders.get( key ); if( oldBorder != border ){ if( border == null ){ borders.remove( key ); } else{ borders.put( key, border ); } for( BasicButtonModelListener listener : listeners() ){ listener.borderChanged( this, key, oldBorder, border ); } } }
/** * Informs this model about the {@link DockController} in whose realm it is used. * @param controller the realm in which this model works */ public void setController( DockController controller ){ if( this.controller != null ){ DockController old = this.controller; this.controller = null; for( BasicButtonModelListener listener : listeners() ){ listener.unbound( this, old ); } } if( controller != null ){ this.controller = controller; for( BasicButtonModelListener listener : listeners() ){ listener.bound( this, this.controller ); } } }
/** * Sets the icon which is normally shown on the view. * @param modifier the context in which to use the icon, not <code>null</code> * @param icon the new icon, can be <code>null</code> */ public void setIcon( ActionContentModifier modifier, Icon icon ){ Icon oldIcon = icons.remove( modifier ); if( icon == null ){ icons.remove( modifier ); } else{ icons.put( modifier, icon ); } disabledIcons.remove( modifier ); for( BasicButtonModelListener listener : listeners() ){ listener.iconChanged( this, modifier, oldIcon, icon ); } changed(); }
/** * Sets the text of this button, some button implementations may ignore the text. * @param text the new text, can be <code>null</code> */ public void setText( String text ){ String oldText = this.text; this.text = text; for( BasicButtonModelListener listener : listeners() ){ listener.textChanged( this, oldText, text ); } changed(); }
/** * Tells this model which orientation the {@link DockTitle} has, on which * the view of this model is displayed. * @param orientation the orientation, not <code>null</code> */ public void setOrientation( Orientation orientation ) { if( orientation == null ) throw new IllegalArgumentException( "Orientation must not be null" ); Orientation old = this.orientation; this.orientation = orientation; for( BasicButtonModelListener listener : listeners() ){ listener.orientationChanged( this, old, orientation ); } changed(); }
/** * Called when the left mouse button has been pressed and released within * the {@link #getOwner() owner} and when this model is {@link #isEnabled() enabled}. */ protected void trigger(){ if( trigger != null ){ trigger.triggered(); } for( BasicButtonModelListener listener : listeners() ){ listener.triggered(); } }
/** * Sets the <code>selected</code> property. The view may be painted in * a different way dependent on this value. * @param selected the new value */ public void setSelected( boolean selected ) { if( this.selected != selected ){ this.selected = selected; for( BasicButtonModelListener listener : listeners() ){ listener.selectedStateChanged( this, selected ); } changed(); } }
/** * Changes the <code>mouseInside</code> property. The property tells whether * the mouse is currently inside the border of the {@link #getOwner() owner} * or not. Clients should not call this method unless they handle all * mouse events. * @param mouseInside whether the mouse is inside */ protected void setMouseInside( boolean mouseInside ) { if( this.mouseInside != mouseInside ){ this.mouseInside = mouseInside; for( BasicButtonModelListener listener : listeners() ){ listener.mouseInside( this, mouseInside ); } changed(); } }
/** * Changes the <code>mousePressed</code> property. The property tells * whether the left mouse button is currently pressed or not. Clients * should not invoke this method unless they handle all mouse events. * @param mousePressed whether button 1 is pressed */ protected void setMousePressed( boolean mousePressed ) { if( this.mousePressed != mousePressed ){ this.mousePressed = mousePressed; for( BasicButtonModelListener listener : listeners() ){ listener.mousePressed( this, mousePressed ); } changed(); } }
/** * Sets the algorithm which should be used to paint the background of the owner. * @param background the background algorithm, can be <code>null</code> * @param backgroundComponent the source of <code>background</code>. Must not be <code>null</code> if * <code>background</code> is not <code>null</code>, must represents {@link #getOwner()} as {@link Component}. */ public void setBackground( BackgroundPaint background, BackgroundComponent backgroundComponent ){ if( this.background != background ){ if( background != null ){ if( backgroundComponent == null ){ throw new IllegalArgumentException( "backgroundComponent must not be null" ); } if( backgroundComponent.getComponent() != getOwner() ){ throw new IllegalArgumentException( "backgroundComponent must exactly represent 'getOwner()'" ); } } BackgroundPaint old = this.background; this.background = background; this.backgroundComponent = backgroundComponent; for( BasicButtonModelListener listener : listeners() ){ listener.backgroundChanged( this, old, background ); } } }
/** * Sets the text which should be used as tooltip. The text is directly * forwarded to the {@link #getOwner() owner} of this model using * {@link JComponent#setToolTipText(String) setToolTipText}. * @param tooltip the text, can be <code>null</code> */ public void setToolTipText( String tooltip ){ String old = owner.getToolTipText(); for( BasicButtonModelListener listener : listeners() ){ listener.tooltipChanged( this, old, tooltip ); } owner.setToolTipText( tooltip ); }
/** * Sets the <code>enabled</code> property of this model. A model will not * react on a mouse-click if it is not enabled. * @param enabled the value */ public void setEnabled( boolean enabled ) { owner.setEnabled( enabled ); if( !enabled ){ setMousePressed( false ); } for( BasicButtonModelListener listener : listeners() ){ listener.enabledStateChanged( this, enabled ); } changed(); }