V - one of the super types of
JLayer's view component
public class LayerUI<V extends Component> extends ComponentUIimplements Serializable
JLayer's UI delegates.
paint(java.awt.Graphics, javax.swing.JComponent) method performs the painting of the JLayer and eventDispatched(AWTEvent, JLayer) method is notified about any AWTEvents which have been generated by a JLayer or any of its subcomponents.
The LayerUI differs from the UI delegates of the other components, because it is LookAndFeel independent and is not updated by default when the system LookAndFeel is changed.
The subclasses of LayerUI can either be stateless and shareable by multiple JLayers or not shareable.
JLayer.setUI(LayerUI) ,
JLayer.setView(Component) ,
JLayer.getView()
| Constructor and Description |
|---|
LayerUI()
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener
Adds a PropertyChangeListener to the listener list.
|
void |
addPropertyChangeListener(String
Adds a PropertyChangeListener to the listener list for a specific property.
|
void |
applyPropertyChange(PropertyChangeEvent
Notifies the
LayerUI when any of its property are changed and enables updating every
JLayer this
LayerUI instance is set to.
|
void |
doLayout(JLayer
Causes the passed instance of
JLayer to lay out its components.
|
void |
eventDispatched(AWTEvent
Processes
AWTEvents for
JLayer and
all its descendants to this
LayerUI instance.
|
protected void |
firePropertyChange(String
Support for reporting bound property changes for Object properties.
|
int |
getBaseline(JComponent
If the
JLayer's view component is not
null, this calls the view's
getBaseline() method.
|
Component |
getBaselineResizeBehavior(JComponent
If the
JLayer's view component is not
null, this returns the result of the view's
getBaselineResizeBehavior() method.
|
Dimension |
getMaximumSize(JComponent
If the
JLayer's view component is not
null, this returns the result of the view's
getMaximumSize() method.
|
Dimension |
getMinimumSize(JComponent
If the
JLayer's view component is not
null, this returns the result of the view's
getMinimalSize() method.
|
Dimension |
getPreferredSize(JComponent
If the
JLayer's view component is not
null, this returns the result of the view's
getPreferredSize() method.
|
PropertyChangeListener |
getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this component.
|
PropertyChangeListener |
getPropertyChangeListeners(String
Returns an array of all the listeners which have been associated with the named property.
|
void |
installUI(JComponent
Configures the
JLayer this
LayerUI is set to.
|
void |
paint(Graphics
Paints the specified component.
|
void |
paintImmediately(int x, int y, int width, int height, JLayer
Paints the specified region in the
JLayer this
LayerUI is set to, immediately.
|
protected void |
processComponentEvent(ComponentEvent
Processes component events occurring on the
JLayer or any of its subcomponents.
|
protected void |
processFocusEvent(FocusEvent
Processes focus events occurring on the
JLayer or any of its subcomponents.
|
protected void |
processHierarchyBoundsEvent(HierarchyEvent
Processes hierarchy bounds event occurring on the
JLayer or any of its subcomponents.
|
protected void |
processHierarchyEvent(HierarchyEvent
Processes hierarchy event occurring on the
JLayer or any of its subcomponents.
|
protected void |
processInputMethodEvent(InputMethodEvent
Processes input event occurring on the
JLayer or any of its subcomponents.
|
protected void |
processKeyEvent(KeyEvent
Processes key events occurring on the
JLayer or any of its subcomponents.
|
protected void |
processMouseEvent(MouseEvent
Processes mouse events occurring on the
JLayer or any of its subcomponents.
|
protected void |
processMouseMotionEvent(MouseEvent
Processes mouse motion event occurring on the
JLayer or any of its subcomponents.
|
protected void |
processMouseWheelEvent(MouseWheelEvent
Processes mouse wheel event occurring on the
JLayer or any of its subcomponents.
|
void |
removePropertyChangeListener(PropertyChangeListener
Removes a PropertyChangeListener from the listener list.
|
void |
removePropertyChangeListener(String
Removes a
PropertyChangeListener from the listener list for a specific property.
|
void |
uninstallUI(JComponent
Reverses the configuration which was previously set in the
installUI(JComponent) method.
|
void |
updateUI(JLayer
|
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, updatepublic void paint(Graphicsg, JComponent c)
Graphics object to render the content of the component.
The default implementation paints the passed component as is.
paint in class
ComponentUI
g - the
Graphics context in which to paint
c - the component being painted
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
public void eventDispatched(AWTEvente, JLayer <? extends V> l)
AWTEvents for
JLayer and
all its descendants to this
LayerUI instance.
To enable the AWTEvents of a particular type, you call JLayer in installUI(javax.swing.JComponent) and set the layer event mask to 0 in uninstallUI(javax.swing.JComponent) after that. By default this method calls the appropriate process<event type>Event method for the given class of event.
Note: Events are processed only for displayable JLayers.
e - the event to be dispatched
l - the layer this LayerUI is set to
JLayer.setLayerEventMask(long) ,
Component.isDisplayable() ,
processComponentEvent(java.awt.event.ComponentEvent, javax.swing.JLayer<? extends V>),
processFocusEvent(java.awt.event.FocusEvent, javax.swing.JLayer<? extends V>),
processKeyEvent(java.awt.event.KeyEvent, javax.swing.JLayer<? extends V>),
processMouseEvent(java.awt.event.MouseEvent, javax.swing.JLayer<? extends V>),
processMouseMotionEvent(java.awt.event.MouseEvent, javax.swing.JLayer<? extends V>),
processInputMethodEvent(java.awt.event.InputMethodEvent, javax.swing.JLayer<? extends V>),
processHierarchyEvent(java.awt.event.HierarchyEvent, javax.swing.JLayer<? extends V>),
processMouseWheelEvent(java.awt.event.MouseWheelEvent, javax.swing.JLayer<? extends V>)
protected void processComponentEvent(ComponentEvente, JLayer <? extends V> l)
JLayer or any of its subcomponents.
This method is not called unless component events are enabled for the JLayer objects, this LayerUI is set to. Component events are enabled in the overridden installUI(javax.swing.JComponent) method and should be disabled in the uninstallUI(javax.swing.JComponent) method after that.
public void installUI(JComponent c) {
super.installUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(AWTEvent.COMPONENT_EVENT_MASK);
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(0);
}
e - the
ComponentEvent to be processed
l - the layer this
LayerUI instance is set to
JLayer.setLayerEventMask(long) ,
installUI(javax.swing.JComponent),
uninstallUI(javax.swing.JComponent)
protected void processFocusEvent(FocusEvente, JLayer <? extends V> l)
JLayer or any of its subcomponents.
This method is not called unless focus events are enabled for the JLayer objects, this LayerUI is set to. Focus events are enabled in the overridden installUI(javax.swing.JComponent) method and should be disabled in the uninstallUI(javax.swing.JComponent) method after that.
public void installUI(JComponent c) {
super.installUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(AWTEvent.FOCUS_EVENT_MASK);
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(0);
}
e - the
FocusEvent to be processed
l - the layer this
LayerUI instance is set to
JLayer.setLayerEventMask(long) ,
installUI(javax.swing.JComponent),
uninstallUI(javax.swing.JComponent)
protected void processKeyEvent(KeyEvente, JLayer <? extends V> l)
JLayer or any of its subcomponents.
This method is not called unless key events are enabled for the JLayer objects, this LayerUI is set to. Key events are enabled in the overridden installUI(javax.swing.JComponent) method and should be disabled in the uninstallUI(javax.swing.JComponent) method after that.
public void installUI(JComponent c) {
super.installUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(AWTEvent.KEY_EVENT_MASK);
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(0);
}
e - the
KeyEvent to be processed
l - the layer this
LayerUI instance is set to
JLayer.setLayerEventMask(long) ,
installUI(javax.swing.JComponent),
uninstallUI(javax.swing.JComponent)
protected void processMouseEvent(MouseEvente, JLayer <? extends V> l)
JLayer or any of its subcomponents.
This method is not called unless mouse events are enabled for the JLayer objects, this LayerUI is set to. Mouse events are enabled in the overridden installUI(javax.swing.JComponent) method and should be disabled in the uninstallUI(javax.swing.JComponent) method after that.
public void installUI(JComponent c) {
super.installUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK);
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(0);
}
e - the
MouseEvent to be processed
l - the layer this
LayerUI instance is set to
JLayer.setLayerEventMask(long) ,
installUI(javax.swing.JComponent),
uninstallUI(javax.swing.JComponent)
protected void processMouseMotionEvent(MouseEvente, JLayer <? extends V> l)
JLayer or any of its subcomponents.
This method is not called unless mouse motion events are enabled for the JLayer objects, this LayerUI is set to. Mouse motion events are enabled in the overridden installUI(javax.swing.JComponent) method and should be disabled in the uninstallUI(javax.swing.JComponent) method after that.
public void installUI(JComponent c) {
super.installUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(AWTEvent.MOUSE_MOTION_EVENT_MASK);
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(0);
}
e - the
MouseEvent to be processed
l - the layer this
LayerUI instance is set to
JLayer.setLayerEventMask(long) ,
installUI(javax.swing.JComponent),
uninstallUI(javax.swing.JComponent)
protected void processMouseWheelEvent(MouseWheelEvente, JLayer <? extends V> l)
JLayer or any of its subcomponents.
This method is not called unless mouse wheel events are enabled for the JLayer objects, this LayerUI is set to. Mouse wheel events are enabled in the overridden installUI(javax.swing.JComponent) method and should be disabled in the uninstallUI(javax.swing.JComponent) method after that.
public void installUI(JComponent c) {
super.installUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(0);
}
e - the
MouseEvent to be processed
l - the layer this
LayerUI instance is set to
JLayer.setLayerEventMask(long) ,
installUI(javax.swing.JComponent),
uninstallUI(javax.swing.JComponent)
protected void processInputMethodEvent(InputMethodEvente, JLayer <? extends V> l)
JLayer or any of its subcomponents.
This method is not called unless input events are enabled for the JLayer objects, this LayerUI is set to. Input events are enabled in the overridden installUI(javax.swing.JComponent) method and should be disabled in the uninstallUI(javax.swing.JComponent) method after that.
public void installUI(JComponent c) {
super.installUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(AWTEvent.INPUT_METHOD_EVENT_MASK);
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(0);
}
e - the
InputMethodEvent to be processed
l - the layer this
LayerUI instance is set to
JLayer.setLayerEventMask(long) ,
installUI(javax.swing.JComponent),
uninstallUI(javax.swing.JComponent)
protected void processHierarchyEvent(HierarchyEvente, JLayer <? extends V> l)
JLayer or any of its subcomponents.
This method is not called unless hierarchy events are enabled for the JLayer objects, this LayerUI is set to. Hierarchy events are enabled in the overridden installUI(javax.swing.JComponent) method and should be disabled in the uninstallUI(javax.swing.JComponent) method after that.
public void installUI(JComponent c) {
super.installUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(AWTEvent.HIERARCHY_EVENT_MASK);
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(0);
}
e - the
HierarchyEvent to be processed
l - the layer this
LayerUI instance is set to
JLayer.setLayerEventMask(long) ,
installUI(javax.swing.JComponent),
uninstallUI(javax.swing.JComponent)
protected void processHierarchyBoundsEvent(HierarchyEvente, JLayer <? extends V> l)
JLayer or any of its subcomponents.
This method is not called unless hierarchy bounds events are enabled for the JLayer objects, this LayerUI is set to. Hierarchy bounds events are enabled in the overridden installUI(javax.swing.JComponent) method and should be disabled in the uninstallUI(javax.swing.JComponent) method after that.
public void installUI(JComponent c) {
super.installUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK);
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
JLayer l = (JLayer) c;
l.setLayerEventMask(0);
}
e - the
HierarchyEvent to be processed
l - the layer this
LayerUI instance is set to
JLayer.setLayerEventMask(long) ,
installUI(javax.swing.JComponent),
uninstallUI(javax.swing.JComponent)
public void installUI(JComponentc)
JLayer this
LayerUI is set to. The default implementation registers the passed
JLayer component as a
PropertyChangeListener for the property changes of this
LayerUI.
installUI in class
ComponentUI
c - the
JLayer component where this UI delegate is being installed
ComponentUI.uninstallUI(javax.swing.JComponent) ,
JComponent.setUI(javax.swing.plaf.ComponentUI) ,
JComponent.updateUI()
public void uninstallUI(JComponentc)
installUI(JComponent) method. The default implementation unregisters the passed
JLayer component as a
PropertyChangeListener for the property changes of this
LayerUI.
uninstallUI in class
ComponentUI
c - the component from which this UI delegate is being removed.
ComponentUI.installUI(javax.swing.JComponent) ,
JComponent.updateUI()
public void addPropertyChangeListener(PropertyChangeListenerlistener)
If listener is null, no exception is thrown and no action is performed.
listener - the property change listener to be added
removePropertyChangeListener(java.beans.PropertyChangeListener),
getPropertyChangeListeners(),
addPropertyChangeListener(String, java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListenerlistener)
If listener is null, no exception is thrown and no action is performed.
listener - the PropertyChangeListener to be removed
addPropertyChangeListener(java.beans.PropertyChangeListener),
getPropertyChangeListeners(),
removePropertyChangeListener(String, PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListeners or an empty array if no property change listeners are currently registered
addPropertyChangeListener(java.beans.PropertyChangeListener),
removePropertyChangeListener(java.beans.PropertyChangeListener),
getPropertyChangeListeners(String)
public void addPropertyChangeListener(StringpropertyName, PropertyChangeListener listener)
If propertyName or listener is null, no exception is thrown and no action is taken.
propertyName - one of the property names listed above
listener - the property change listener to be added
removePropertyChangeListener(String, PropertyChangeListener),
getPropertyChangeListeners(String),
addPropertyChangeListener(String, PropertyChangeListener)
public void removePropertyChangeListener(StringpropertyName, PropertyChangeListener listener)
PropertyChangeListener from the listener list for a specific property. This method should be used to remove
PropertyChangeListeners that were registered for a specific bound property.
If propertyName or listener is null, no exception is thrown and no action is taken.
propertyName - a valid property name
listener - the PropertyChangeListener to be removed
addPropertyChangeListener(String, PropertyChangeListener),
getPropertyChangeListeners(String),
removePropertyChangeListener(PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
propertyName - The name of the property being listened to
PropertyChangeListeners associated with the named property; if no such listeners have been added or if
propertyName is
null, an empty array is returned
addPropertyChangeListener(String, PropertyChangeListener),
removePropertyChangeListener(String, PropertyChangeListener),
getPropertyChangeListeners()
protected void firePropertyChange(StringpropertyName, Object oldValue, Object newValue)
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value
public void applyPropertyChange(PropertyChangeEventevt, JLayer <? extends V> l)
LayerUI when any of its property are changed and enables updating every
JLayer this
LayerUI instance is set to.
evt - the PropertyChangeEvent generated by this
LayerUI
l - the
JLayer this LayerUI is set to
public int getBaseline(JComponentc, int width, int height)
JLayer's view component is not
null, this calls the view's
getBaseline() method. Otherwise, the default implementation is called.
getBaseline in class
ComponentUI
c -
JLayer to return baseline resize behavior for
width - the width to get the baseline for
height - the height to get the baseline for
JComponent.getBaseline(int,int)
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
JLayer's view component is not
null, this returns the result of the view's
getBaselineResizeBehavior() method. Otherwise, the default implementation is called.
getBaselineResizeBehavior in class
ComponentUI
c -
JLayer to return baseline resize behavior for
JComponent.getBaseline(int, int)
public void doLayout(JLayer<? extends V> l)
JLayer to lay out its components.
l - the
JLayer component where this UI delegate is being installed
public DimensiongetPreferredSize(JComponent c)
JLayer's view component is not
null, this returns the result of the view's
getPreferredSize() method. Otherwise, the default implementation is used.
getPreferredSize in class
ComponentUI
c -
JLayer to return preferred size for
JLayer
JComponent.getPreferredSize() ,
LayoutManager.preferredLayoutSize(java.awt.Container)
public DimensiongetMinimumSize(JComponent c)
JLayer's view component is not
null, this returns the result of the view's
getMinimalSize() method. Otherwise, the default implementation is used.
getMinimumSize in class
ComponentUI
c -
JLayer to return preferred size for
JLayer
JComponent.getMinimumSize() ,
LayoutManager.minimumLayoutSize(java.awt.Container) ,
ComponentUI.getPreferredSize(javax.swing.JComponent)
public DimensiongetMaximumSize(JComponent c)
JLayer's view component is not
null, this returns the result of the view's
getMaximumSize() method. Otherwise, the default implementation is used.
getMaximumSize in class
ComponentUI
c -
JLayer to return preferred size for
JLayer
JComponent.getMaximumSize() ,
LayoutManager2.maximumLayoutSize(java.awt.Container)
public void paintImmediately(int x,
int y,
int width,
int height,
JLayer<? extends V> l)
JLayer this
LayerUI is set to, immediately.
This method is to be overridden when the dirty region needs to be changed. The default implementation delegates its functionality to JComponent.
x - the x value of the region to be painted
y - the y value of the region to be painted
width - the width of the region to be painted
height - the height of the region to be painted
JComponent.paintImmediately(int, int, int, int)