Class LayerUI<V extends Component>
- Type Parameters:
V- one of the super types ofJLayer's view component
- All Implemented Interfaces:
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.
- Since:
- 1.7
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a PropertyChangeListener to the listener list.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Adds a PropertyChangeListener to the listener list for a specific property.voidapplyPropertyChange(PropertyChangeEvent evt, JLayer<? extends V> l) Notifies theLayerUIwhen any of its property are changed and enables updating everyJLayerthisLayerUIinstance is set to.voidCauses the passed instance ofJLayerto lay out its components.voideventDispatched(AWTEvent e, JLayer<? extends V> l) ProcessesAWTEvents forJLayerand all its descendants to thisLayerUIinstance.protected voidfirePropertyChange(String propertyName, Object oldValue, Object newValue) Support for reporting bound property changes for Object properties.intgetBaseline(JComponent c, int width, int height) If theJLayer's view component is notnull, this calls the view'sgetBaseline()method.If theJLayer's view component is notnull, this returns the result of the view'sgetBaselineResizeBehavior()method.If theJLayer's view component is notnull, this returns the result of the view'sgetMaximumSize()method.If theJLayer's view component is notnull, this returns the result of the view'sgetMinimalSize()method.If theJLayer's view component is notnull, this returns the result of the view'sgetPreferredSize()method.Returns an array of all the property change listeners registered on this component.getPropertyChangeListeners(String propertyName) Returns an array of all the listeners which have been associated with the named property.booleanimageUpdate(Image img, int infoflags, int x, int y, int w, int h, JLayer<? extends V> l) Delegates its functionality to the default implementation of theJLayer.imageUpdatemethod which is inherited fromJLayer's base classes.voidConfigures theJLayerthisLayerUIis set to.voidpaint(Graphics g, JComponent c) Paints the specified component.voidpaintImmediately(int x, int y, int width, int height, JLayer<? extends V> l) Paints the specified region in theJLayerthisLayerUIis set to, immediately.protected voidprocessComponentEvent(ComponentEvent e, JLayer<? extends V> l) Processes component events occurring on theJLayeror any of its subcomponents.protected voidprocessFocusEvent(FocusEvent e, JLayer<? extends V> l) Processes focus events occurring on theJLayeror any of its subcomponents.protected voidprocessHierarchyBoundsEvent(HierarchyEvent e, JLayer<? extends V> l) Processes hierarchy bounds event occurring on theJLayeror any of its subcomponents.protected voidprocessHierarchyEvent(HierarchyEvent e, JLayer<? extends V> l) Processes hierarchy event occurring on theJLayeror any of its subcomponents.protected voidprocessInputMethodEvent(InputMethodEvent e, JLayer<? extends V> l) Processes input event occurring on theJLayeror any of its subcomponents.protected voidprocessKeyEvent(KeyEvent e, JLayer<? extends V> l) Processes key events occurring on theJLayeror any of its subcomponents.protected voidprocessMouseEvent(MouseEvent e, JLayer<? extends V> l) Processes mouse events occurring on theJLayeror any of its subcomponents.protected voidprocessMouseMotionEvent(MouseEvent e, JLayer<? extends V> l) Processes mouse motion event occurring on theJLayeror any of its subcomponents.protected voidprocessMouseWheelEvent(MouseWheelEvent e, JLayer<? extends V> l) Processes mouse wheel event occurring on theJLayeror any of its subcomponents.voidRemoves a PropertyChangeListener from the listener list.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Removes aPropertyChangeListenerfrom the listener list for a specific property.voidReverses the configuration which was previously set in theinstallUI(JComponent)method.voidMethods declared in class javax.swing.plaf.ComponentUI
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, update
-
Constructor Details
-
LayerUI
public LayerUI()Constructs aLayerUI.
-
-
Method Details
-
paint
Paints the specified component. Subclasses should override this method and use the specifiedGraphicsobject to render the content of the component.The default implementation paints the passed component as is.
- Overrides:
paintin classComponentUI- Parameters:
g- theGraphicscontext in which to paintc- the component being painted- See Also:
-
eventDispatched
ProcessesAWTEvents forJLayerand all its descendants to thisLayerUIinstance.To enable the
AWTEvents of a particular type, you callJLayer.setLayerEventMask(long)ininstallUI(javax.swing.JComponent)and set the layer event mask to0inuninstallUI(javax.swing.JComponent)after that. By default this method calls the appropriateprocess<eventtype>Eventmethod for the given class of event.Note: Events are processed only for displayable
JLayers.- Parameters:
e- the event to be dispatchedl- the layer this LayerUI is set to- See Also:
-
processComponentEvent
Processes component events occurring on theJLayeror any of its subcomponents.This method is not called unless component events are enabled for the
JLayerobjects, thisLayerUIis set to. Component events are enabled in the overriddeninstallUI(javax.swing.JComponent)method and should be disabled in theuninstallUI(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); }- Parameters:
e- theComponentEventto be processedl- the layer thisLayerUIinstance is set to- See Also:
-
processFocusEvent
Processes focus events occurring on theJLayeror any of its subcomponents.This method is not called unless focus events are enabled for the
JLayerobjects, thisLayerUIis set to. Focus events are enabled in the overriddeninstallUI(javax.swing.JComponent)method and should be disabled in theuninstallUI(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); }- Parameters:
e- theFocusEventto be processedl- the layer thisLayerUIinstance is set to- See Also:
-
processKeyEvent
Processes key events occurring on theJLayeror any of its subcomponents.This method is not called unless key events are enabled for the
JLayerobjects, thisLayerUIis set to. Key events are enabled in the overriddeninstallUI(javax.swing.JComponent)method and should be disabled in theuninstallUI(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); }- Parameters:
e- theKeyEventto be processedl- the layer thisLayerUIinstance is set to- See Also:
-
processMouseEvent
Processes mouse events occurring on theJLayeror any of its subcomponents.This method is not called unless mouse events are enabled for the
JLayerobjects, thisLayerUIis set to. Mouse events are enabled in the overriddeninstallUI(javax.swing.JComponent)method and should be disabled in theuninstallUI(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); }- Parameters:
e- theMouseEventto be processedl- the layer thisLayerUIinstance is set to- See Also:
-
processMouseMotionEvent
Processes mouse motion event occurring on theJLayeror any of its subcomponents.This method is not called unless mouse motion events are enabled for the
JLayerobjects, thisLayerUIis set to. Mouse motion events are enabled in the overriddeninstallUI(javax.swing.JComponent)method and should be disabled in theuninstallUI(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); }- Parameters:
e- theMouseEventto be processedl- the layer thisLayerUIinstance is set to- See Also:
-
processMouseWheelEvent
Processes mouse wheel event occurring on theJLayeror any of its subcomponents.This method is not called unless mouse wheel events are enabled for the
JLayerobjects, thisLayerUIis set to. Mouse wheel events are enabled in the overriddeninstallUI(javax.swing.JComponent)method and should be disabled in theuninstallUI(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); }- Parameters:
e- theMouseEventto be processedl- the layer thisLayerUIinstance is set to- See Also:
-
processInputMethodEvent
Processes input event occurring on theJLayeror any of its subcomponents.This method is not called unless input events are enabled for the
JLayerobjects, thisLayerUIis set to. Input events are enabled in the overriddeninstallUI(javax.swing.JComponent)method and should be disabled in theuninstallUI(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); }- Parameters:
e- theInputMethodEventto be processedl- the layer thisLayerUIinstance is set to- See Also:
-
processHierarchyEvent
Processes hierarchy event occurring on theJLayeror any of its subcomponents.This method is not called unless hierarchy events are enabled for the
JLayerobjects, thisLayerUIis set to. Hierarchy events are enabled in the overriddeninstallUI(javax.swing.JComponent)method and should be disabled in theuninstallUI(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); }- Parameters:
e- theHierarchyEventto be processedl- the layer thisLayerUIinstance is set to- See Also:
-
processHierarchyBoundsEvent
Processes hierarchy bounds event occurring on theJLayeror any of its subcomponents.This method is not called unless hierarchy bounds events are enabled for the
JLayerobjects, thisLayerUIis set to. Hierarchy bounds events are enabled in the overriddeninstallUI(javax.swing.JComponent)method and should be disabled in theuninstallUI(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); }- Parameters:
e- theHierarchyEventto be processedl- the layer thisLayerUIinstance is set to- See Also:
-
updateUI
- Parameters:
l- theJLayerwhich UI is updated
-
installUI
Configures theJLayerthisLayerUIis set to. The default implementation registers the passedJLayercomponent as aPropertyChangeListenerfor the property changes of thisLayerUI.- Overrides:
installUIin classComponentUI- Parameters:
c- theJLayercomponent where this UI delegate is being installed- See Also:
-
uninstallUI
Reverses the configuration which was previously set in theinstallUI(JComponent)method. The default implementation unregisters the passedJLayercomponent as aPropertyChangeListenerfor the property changes of thisLayerUI.- Overrides:
uninstallUIin classComponentUI- Parameters:
c- the component from which this UI delegate is being removed.- See Also:
-
addPropertyChangeListener
Adds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class.If
listenerisnull, no exception is thrown and no action is performed.- Parameters:
listener- the property change listener to be added- See Also:
-
removePropertyChangeListener
Removes a PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.If
listenerisnull, no exception is thrown and no action is performed.- Parameters:
listener- the PropertyChangeListener to be removed- See Also:
-
getPropertyChangeListeners
Returns an array of all the property change listeners registered on this component.- Returns:
- all of this ui's
PropertyChangeListeners or an empty array if no property change listeners are currently registered - See Also:
-
addPropertyChangeListener
Adds a PropertyChangeListener to the listener list for a specific property.If
propertyNameorlistenerisnull, no exception is thrown and no action is taken.- Parameters:
propertyName- one of the property names listed abovelistener- the property change listener to be added- See Also:
-
removePropertyChangeListener
Removes aPropertyChangeListenerfrom the listener list for a specific property. This method should be used to removePropertyChangeListeners that were registered for a specific bound property.If
propertyNameorlistenerisnull, no exception is thrown and no action is taken.- Parameters:
propertyName- a valid property namelistener- the PropertyChangeListener to be removed- See Also:
-
getPropertyChangeListeners
Returns an array of all the listeners which have been associated with the named property.- Parameters:
propertyName- The name of the property being listened to- Returns:
- all of the
PropertyChangeListeners associated with the named property; if no such listeners have been added or ifpropertyNameisnull, an empty array is returned - See Also:
-
firePropertyChange
Support for reporting bound property changes for Object properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.- Parameters:
propertyName- the property whose value has changedoldValue- the property's previous valuenewValue- the property's new value
-
applyPropertyChange
Notifies theLayerUIwhen any of its property are changed and enables updating everyJLayerthisLayerUIinstance is set to.- Parameters:
evt- the PropertyChangeEvent generated by thisLayerUIl- theJLayerthis LayerUI is set to
-
getBaseline
If theJLayer's view component is notnull, this calls the view'sgetBaseline()method. Otherwise, the default implementation is called.- Overrides:
getBaselinein classComponentUI- Parameters:
c-JLayerto return baseline resize behavior forwidth- the width to get the baseline forheight- the height to get the baseline for- Returns:
- baseline or a value < 0 indicating there is no reasonable baseline
- See Also:
-
getBaselineResizeBehavior
If theJLayer's view component is notnull, this returns the result of the view'sgetBaselineResizeBehavior()method. Otherwise, the default implementation is called.- Overrides:
getBaselineResizeBehaviorin classComponentUI- Parameters:
c-JLayerto return baseline resize behavior for- Returns:
- an enum indicating how the baseline changes as the component size changes
- See Also:
-
doLayout
-
getPreferredSize
If theJLayer's view component is notnull, this returns the result of the view'sgetPreferredSize()method. Otherwise, the default implementation is used.- Overrides:
getPreferredSizein classComponentUI- Parameters:
c-JLayerto return preferred size for- Returns:
- preferred size for the passed
JLayer - See Also:
-
getMinimumSize
If theJLayer's view component is notnull, this returns the result of the view'sgetMinimalSize()method. Otherwise, the default implementation is used.- Overrides:
getMinimumSizein classComponentUI- Parameters:
c-JLayerto return preferred size for- Returns:
- minimal size for the passed
JLayer - See Also:
-
getMaximumSize
If theJLayer's view component is notnull, this returns the result of the view'sgetMaximumSize()method. Otherwise, the default implementation is used.- Overrides:
getMaximumSizein classComponentUI- Parameters:
c-JLayerto return preferred size for- Returns:
- maximum size for the passed
JLayer - See Also:
-
paintImmediately
Paints the specified region in theJLayerthisLayerUIis 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.paintImmediately(int, int, int, int).- Parameters:
x- the x value of the region to be paintedy- the y value of the region to be paintedwidth- the width of the region to be paintedheight- the height of the region to be paintedl- aJLayercomponent- See Also:
-
imageUpdate
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h, JLayer<? extends V> l) Delegates its functionality to the default implementation of theJLayer.imageUpdatemethod which is inherited fromJLayer's base classes.This method is to be overridden instead of
JLayer.imageUpdate.Note: This method is usually called not on the Event Dispatching Thread.
- Parameters:
img- the image being observedinfoflags- see imageUpdate for informationx- the x coordinatey- the y coordinatew- the widthh- the heightl- aJLayercomponent- Returns:
- false if the infoflags indicate that the image is completely loaded; true otherwise
-