- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- javax.swing.plaf.LayerUI<V>
-
- Type Parameters:
V
- one of the super types ofJLayer
's view component
- All Implemented Interfaces:
- Serializable
public class LayerUI<V extends Component> extends ComponentUI implements Serializable
The base class for allJLayer
's UI delegates.paint(java.awt.Graphics, javax.swing.JComponent)
method performs the painting of theJLayer
andeventDispatched(AWTEvent, JLayer)
method is notified about anyAWTEvent
s which have been generated by aJLayer
or any of its subcomponents. TheLayerUI
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 ofLayerUI
can either be stateless and shareable by multipleJLayer
s or not shareable.- Since:
- 1.7
- See Also:
JLayer.setUI(LayerUI)
,JLayer.setView(Component)
,JLayer.getView()
-
-
Constructor Summary
Constructors Constructor and Description LayerUI()
-
Method Summary
Methods Modifier and Type Method and Description void
addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list.void
addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property.void
applyPropertyChange(PropertyChangeEvent evt, JLayer<? extends V> l)
Notifies theLayerUI
when any of its property are changed and enables updating everyJLayer
thisLayerUI
instance is set to.void
doLayout(JLayer<? extends V> l)
Causes the passed instance ofJLayer
to lay out its components.void
eventDispatched(AWTEvent e, JLayer<? extends V> l)
ProcessesAWTEvent
s forJLayer
and all its descendants to thisLayerUI
instance.protected void
firePropertyChange(String propertyName, Object oldValue, Object newValue)
Support for reporting bound property changes for Object properties.int
getBaseline(JComponent c, int width, int height)
If theJLayer
's view component is notnull
, this calls the view'sgetBaseline()
method.Component.BaselineResizeBehavior
getBaselineResizeBehavior(JComponent c)
If theJLayer
's view component is notnull
, this returns the result of the view'sgetBaselineResizeBehavior()
method.Dimension
getMaximumSize(JComponent c)
If theJLayer
's view component is notnull
, this returns the result of the view'sgetMaximumSize()
method.Dimension
getMinimumSize(JComponent c)
If theJLayer
's view component is notnull
, this returns the result of the view'sgetMinimalSize()
method.Dimension
getPreferredSize(JComponent c)
If theJLayer
's view component is notnull
, this returns the result of the view'sgetPreferredSize()
method.PropertyChangeListener[]
getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this component.PropertyChangeListener[]
getPropertyChangeListeners(String propertyName)
Returns an array of all the listeners which have been associated with the named property.void
installUI(JComponent c)
Configures theJLayer
thisLayerUI
is set to.void
paint(Graphics g, JComponent c)
Paints the specified component.void
paintImmediately(int x, int y, int width, int height, JLayer<? extends V> l)
Paints the specified region in theJLayer
thisLayerUI
is set to, immediately.protected void
processComponentEvent(ComponentEvent e, JLayer<? extends V> l)
Processes component events occurring on theJLayer
or any of its subcomponents.protected void
processFocusEvent(FocusEvent e, JLayer<? extends V> l)
Processes focus events occurring on theJLayer
or any of its subcomponents.protected void
processHierarchyBoundsEvent(HierarchyEvent e, JLayer<? extends V> l)
Processes hierarchy bounds event occurring on theJLayer
or any of its subcomponents.protected void
processHierarchyEvent(HierarchyEvent e, JLayer<? extends V> l)
Processes hierarchy event occurring on theJLayer
or any of its subcomponents.protected void
processInputMethodEvent(InputMethodEvent e, JLayer<? extends V> l)
Processes input event occurring on theJLayer
or any of its subcomponents.protected void
processKeyEvent(KeyEvent e, JLayer<? extends V> l)
Processes key events occurring on theJLayer
or any of its subcomponents.protected void
processMouseEvent(MouseEvent e, JLayer<? extends V> l)
Processes mouse events occurring on theJLayer
or any of its subcomponents.protected void
processMouseMotionEvent(MouseEvent e, JLayer<? extends V> l)
Processes mouse motion event occurring on theJLayer
or any of its subcomponents.protected void
processMouseWheelEvent(MouseWheelEvent e, JLayer<? extends V> l)
Processes mouse wheel event occurring on theJLayer
or any of its subcomponents.void
removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list.void
removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
Removes aPropertyChangeListener
from the listener list for a specific property.void
uninstallUI(JComponent c)
Reverses the configuration which was previously set in theinstallUI(JComponent)
method.void
updateUI(JLayer<? extends V> l)
-
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, update
-
-
-
-
Method Detail
-
paint
public void paint(Graphics g, JComponent c)
Paints the specified component. Subclasses should override this method and use the specifiedGraphics
object to render the content of the component. The default implementation paints the passed component as is.- Overrides:
paint
in classComponentUI
- Parameters:
g
- theGraphics
context in which to paintc
- the component being painted- See Also:
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
-
eventDispatched
public void eventDispatched(AWTEvent e, JLayer<? extends V> l)
ProcessesAWTEvent
s forJLayer
and all its descendants to thisLayerUI
instance. To enable theAWTEvent
s of a particular type, you callJLayer.setLayerEventMask(long)
ininstallUI(javax.swing.JComponent)
and set the layer event mask to0
inuninstallUI(javax.swing.JComponent)
after that. By default this method calls the appropriateprocess<event type>Event
method for the given class of event. Note: Events are processed only for displayableJLayer
s.- Parameters:
e
- the event to be dispatchedl
- the layer this LayerUI is set to- See Also:
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>)
-
processComponentEvent
protected void processComponentEvent(ComponentEvent e, JLayer<? extends V> l)
Processes component events occurring on theJLayer
or any of its subcomponents. This method is not called unless component events are enabled for theJLayer
objects, thisLayerUI
is 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
- theComponentEvent
to be processedl
- the layer thisLayerUI
instance is set to- See Also:
JLayer.setLayerEventMask(long)
,installUI(javax.swing.JComponent)
,uninstallUI(javax.swing.JComponent)
-
processFocusEvent
protected void processFocusEvent(FocusEvent e, JLayer<? extends V> l)
Processes focus events occurring on theJLayer
or any of its subcomponents. This method is not called unless focus events are enabled for theJLayer
objects, thisLayerUI
is 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
- theFocusEvent
to be processedl
- the layer thisLayerUI
instance is set to- See Also:
JLayer.setLayerEventMask(long)
,installUI(javax.swing.JComponent)
,uninstallUI(javax.swing.JComponent)
-
processKeyEvent
protected void processKeyEvent(KeyEvent e, JLayer<? extends V> l)
Processes key events occurring on theJLayer
or any of its subcomponents. This method is not called unless key events are enabled for theJLayer
objects, thisLayerUI
is 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
- theKeyEvent
to be processedl
- the layer thisLayerUI
instance is set to- See Also:
JLayer.setLayerEventMask(long)
,installUI(javax.swing.JComponent)
,uninstallUI(javax.swing.JComponent)
-
processMouseEvent
protected void processMouseEvent(MouseEvent e, JLayer<? extends V> l)
Processes mouse events occurring on theJLayer
or any of its subcomponents. This method is not called unless mouse events are enabled for theJLayer
objects, thisLayerUI
is 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
- theMouseEvent
to be processedl
- the layer thisLayerUI
instance is set to- See Also:
JLayer.setLayerEventMask(long)
,installUI(javax.swing.JComponent)
,uninstallUI(javax.swing.JComponent)
-
processMouseMotionEvent
protected void processMouseMotionEvent(MouseEvent e, JLayer<? extends V> l)
Processes mouse motion event occurring on theJLayer
or any of its subcomponents. This method is not called unless mouse motion events are enabled for theJLayer
objects, thisLayerUI
is 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
- theMouseEvent
to be processedl
- the layer thisLayerUI
instance is set to- See Also:
JLayer.setLayerEventMask(long)
,installUI(javax.swing.JComponent)
,uninstallUI(javax.swing.JComponent)
-
processMouseWheelEvent
protected void processMouseWheelEvent(MouseWheelEvent e, JLayer<? extends V> l)
Processes mouse wheel event occurring on theJLayer
or any of its subcomponents. This method is not called unless mouse wheel events are enabled for theJLayer
objects, thisLayerUI
is 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
- theMouseEvent
to be processedl
- the layer thisLayerUI
instance is set to- See Also:
JLayer.setLayerEventMask(long)
,installUI(javax.swing.JComponent)
,uninstallUI(javax.swing.JComponent)
-
processInputMethodEvent
protected void processInputMethodEvent(InputMethodEvent e, JLayer<? extends V> l)
Processes input event occurring on theJLayer
or any of its subcomponents. This method is not called unless input events are enabled for theJLayer
objects, thisLayerUI
is 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
- theInputMethodEvent
to be processedl
- the layer thisLayerUI
instance is set to- See Also:
JLayer.setLayerEventMask(long)
,installUI(javax.swing.JComponent)
,uninstallUI(javax.swing.JComponent)
-
processHierarchyEvent
protected void processHierarchyEvent(HierarchyEvent e, JLayer<? extends V> l)
Processes hierarchy event occurring on theJLayer
or any of its subcomponents. This method is not called unless hierarchy events are enabled for theJLayer
objects, thisLayerUI
is 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
- theHierarchyEvent
to be processedl
- the layer thisLayerUI
instance is set to- See Also:
JLayer.setLayerEventMask(long)
,installUI(javax.swing.JComponent)
,uninstallUI(javax.swing.JComponent)
-
processHierarchyBoundsEvent
protected void processHierarchyBoundsEvent(HierarchyEvent e, JLayer<? extends V> l)
Processes hierarchy bounds event occurring on theJLayer
or any of its subcomponents. This method is not called unless hierarchy bounds events are enabled for theJLayer
objects, thisLayerUI
is 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
- theHierarchyEvent
to be processedl
- the layer thisLayerUI
instance is set to- See Also:
JLayer.setLayerEventMask(long)
,installUI(javax.swing.JComponent)
,uninstallUI(javax.swing.JComponent)
-
installUI
public void installUI(JComponent c)
Configures theJLayer
thisLayerUI
is set to. The default implementation registers the passedJLayer
component as aPropertyChangeListener
for the property changes of thisLayerUI
.- Overrides:
installUI
in classComponentUI
- Parameters:
c
- theJLayer
component where this UI delegate is being installed- See Also:
ComponentUI.uninstallUI(javax.swing.JComponent)
,JComponent.setUI(javax.swing.plaf.ComponentUI)
,JComponent.updateUI()
-
uninstallUI
public void uninstallUI(JComponent c)
Reverses the configuration which was previously set in theinstallUI(JComponent)
method. The default implementation unregisters the passedJLayer
component as aPropertyChangeListener
for the property changes of thisLayerUI
.- Overrides:
uninstallUI
in classComponentUI
- Parameters:
c
- the component from which this UI delegate is being removed.- See Also:
ComponentUI.installUI(javax.swing.JComponent)
,JComponent.updateUI()
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class. Iflistener
isnull
, no exception is thrown and no action is performed.- Parameters:
listener
- the property change listener to be added- See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)
,getPropertyChangeListeners()
,addPropertyChangeListener(String, java.beans.PropertyChangeListener)
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
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. Iflistener
isnull
, no exception is thrown and no action is performed.- Parameters:
listener
- the PropertyChangeListener to be removed- See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)
,getPropertyChangeListeners()
,removePropertyChangeListener(String, PropertyChangeListener)
-
getPropertyChangeListeners
public PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this component.- Returns:
- all of this ui's
PropertyChangeListener
s or an empty array if no property change listeners are currently registered - See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)
,removePropertyChangeListener(java.beans.PropertyChangeListener)
,getPropertyChangeListeners(String)
-
addPropertyChangeListener
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property. IfpropertyName
orlistener
isnull
, 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(String, PropertyChangeListener)
,getPropertyChangeListeners(String)
,addPropertyChangeListener(String, PropertyChangeListener)
-
removePropertyChangeListener
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
Removes aPropertyChangeListener
from the listener list for a specific property. This method should be used to removePropertyChangeListener
s that were registered for a specific bound property. IfpropertyName
orlistener
isnull
, no exception is thrown and no action is taken.- Parameters:
propertyName
- a valid property namelistener
- the PropertyChangeListener to be removed- See Also:
addPropertyChangeListener(String, PropertyChangeListener)
,getPropertyChangeListeners(String)
,removePropertyChangeListener(PropertyChangeListener)
-
getPropertyChangeListeners
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
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
PropertyChangeListener
s associated with the named property; if no such listeners have been added or ifpropertyName
isnull
, an empty array is returned - See Also:
addPropertyChangeListener(String, PropertyChangeListener)
,removePropertyChangeListener(String, PropertyChangeListener)
,getPropertyChangeListeners()
-
firePropertyChange
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
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
public void applyPropertyChange(PropertyChangeEvent evt, JLayer<? extends V> l)
Notifies theLayerUI
when any of its property are changed and enables updating everyJLayer
thisLayerUI
instance is set to.- Parameters:
evt
- the PropertyChangeEvent generated by thisLayerUI
l
- theJLayer
this LayerUI is set to
-
getBaseline
public int getBaseline(JComponent c, int width, int height)
If theJLayer
's view component is notnull
, this calls the view'sgetBaseline()
method. Otherwise, the default implementation is called.- Overrides:
getBaseline
in classComponentUI
- Parameters:
c
-JLayer
to 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:
JComponent.getBaseline(int,int)
-
getBaselineResizeBehavior
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
If theJLayer
's view component is notnull
, this returns the result of the view'sgetBaselineResizeBehavior()
method. Otherwise, the default implementation is called.- Overrides:
getBaselineResizeBehavior
in classComponentUI
- Parameters:
c
-JLayer
to return baseline resize behavior for- Returns:
- an enum indicating how the baseline changes as the component size changes
- See Also:
JComponent.getBaseline(int, int)
-
doLayout
public void doLayout(JLayer<? extends V> l)
Causes the passed instance ofJLayer
to lay out its components.- Parameters:
l
- theJLayer
component where this UI delegate is being installed
-
getPreferredSize
public Dimension getPreferredSize(JComponent c)
If theJLayer
's view component is notnull
, this returns the result of the view'sgetPreferredSize()
method. Otherwise, the default implementation is used.- Overrides:
getPreferredSize
in classComponentUI
- Parameters:
c
-JLayer
to return preferred size for- Returns:
- preferred size for the passed
JLayer
- See Also:
JComponent.getPreferredSize()
,LayoutManager.preferredLayoutSize(java.awt.Container)
-
getMinimumSize
public Dimension getMinimumSize(JComponent c)
If theJLayer
's view component is notnull
, this returns the result of the view'sgetMinimalSize()
method. Otherwise, the default implementation is used.- Overrides:
getMinimumSize
in classComponentUI
- Parameters:
c
-JLayer
to return preferred size for- Returns:
- minimal size for the passed
JLayer
- See Also:
JComponent.getMinimumSize()
,LayoutManager.minimumLayoutSize(java.awt.Container)
,ComponentUI.getPreferredSize(javax.swing.JComponent)
-
getMaximumSize
public Dimension getMaximumSize(JComponent c)
If theJLayer
's view component is notnull
, this returns the result of the view'sgetMaximumSize()
method. Otherwise, the default implementation is used.- Overrides:
getMaximumSize
in classComponentUI
- Parameters:
c
-JLayer
to return preferred size for- Returns:
- maximum size for the passed
JLayer
- See Also:
JComponent.getMaximumSize()
,LayoutManager2.maximumLayoutSize(java.awt.Container)
-
paintImmediately
public void paintImmediately(int x, int y, int width, int height, JLayer<? extends V> l)
Paints the specified region in theJLayer
thisLayerUI
is set to, immediately. This method is to be overridden when the dirty region needs to be changed. The default implementation delegates its functionality toJComponent.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 painted- See Also:
JComponent.paintImmediately(int, int, int, int)
-
-
Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-javax/swing/plaf/LayerUI.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.