3909N/A * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. 1621N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1621N/A * This code is free software; you can redistribute it and/or modify it 1621N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 1621N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 1621N/A * This code is distributed in the hope that it will be useful, but WITHOUT 1621N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1621N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1621N/A * version 2 for more details (a copy is included in the LICENSE file that 1621N/A * You should have received a copy of the GNU General Public License version 1621N/A * 2 along with this work; if not, write to the Free Software Foundation, 1621N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 1561N/A * The base class for all {@link javax.swing.JLayer}'s UI delegates. 3829N/A * {@link #paint(java.awt.Graphics, javax.swing.JComponent)} method performs the 1561N/A * painting of the {@code JLayer} 1561N/A * and {@link #eventDispatched(AWTEvent, JLayer)} method is notified 1561N/A * about any {@code AWTEvent}s which have been generated by a {@code JLayer} 1561N/A * or any of its subcomponents. 1561N/A * The {@code LayerUI} differs from the UI delegates of the other components, 1561N/A * because it is LookAndFeel independent and is not updated by default when 1561N/A * the system LookAndFeel is changed. 1561N/A * The subclasses of {@code LayerUI} can either be stateless and shareable 1561N/A * by multiple {@code JLayer}s or not shareable. 1561N/A * @param <V> one of the super types of {@code JLayer}'s view component 1561N/A * @see JLayer#setUI(LayerUI) 1561N/A * @see JLayer#setView(Component) 1561N/A * @author Alexander Potochkin 1561N/A * Paints the specified component. 1561N/A * Subclasses should override this method and use 1561N/A * the specified {@code Graphics} object to 1561N/A * render the content of the component. 2334N/A * The default implementation paints the passed component as is. 2334N/A * @param g the {@code Graphics} context in which to paint 2334N/A * @param c the component being painted 2335N/A * Processes {@code AWTEvent}s for {@code JLayer} 2335N/A * and <b>all its descendants</b> to this {@code LayerUI} instance. 1910N/A * To enable the {@code AWTEvent}s of a particular type, 1910N/A * you call {@link JLayer#setLayerEventMask} 1561N/A * in {@link #installUI(javax.swing.JComponent)} 1561N/A * and set the layer event mask to {@code 0} 1910N/A * in {@link #uninstallUI(javax.swing.JComponent)} after that. 1910N/A * By default this method calls the appropriate 1910N/A * {@code process<event type>Event} 1910N/A * method for the given class of event. 2335N/A * <b>Note:</b> Events are processed only for displayable {@code JLayer}s. 1561N/A * @param e the event to be dispatched 1561N/A * @param l the layer this LayerUI is set to 1561N/A * @see JLayer#setLayerEventMask(long) 2335N/A * @see Component#isDisplayable() 1910N/A * @see #processComponentEvent 1910N/A * @see #processMouseMotionEvent 1910N/A * @see #processInputMethodEvent 1910N/A * @see #processHierarchyEvent 1910N/A * @see #processMouseWheelEvent 1910N/A * Processes component events occurring on the {@link JLayer} 1910N/A * or any of its subcomponents. 1910N/A * This method is not called unless component events are 1910N/A * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to. 1910N/A * Component events are enabled in the overridden {@link #installUI} method 1910N/A * and should be disabled in the {@link #uninstallUI} method after that. 1910N/A * public void installUI(JComponent c) { 1910N/A * l.setLayerEventMask(AWTEvent.COMPONENT_EVENT_MASK); 3829N/A * public void uninstallUI(JComponent c) { 1910N/A * @param e the {@code ComponentEvent} to be processed 1910N/A * @param l the layer this {@code LayerUI} instance is set to 1910N/A * @see JLayer#setLayerEventMask(long) 1910N/A * @see #installUI(javax.swing.JComponent) 1910N/A * @see #uninstallUI(javax.swing.JComponent) 1910N/A * Processes focus events occurring on the {@link JLayer} 1910N/A * or any of its subcomponents. 1910N/A * This method is not called unless focus events are 1910N/A * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to. 1910N/A * Focus events are enabled in the overridden {@link #installUI} method 1910N/A * and should be disabled in the {@link #uninstallUI} method after that. 1910N/A * public void installUI(JComponent c) { 1910N/A * l.setLayerEventMask(AWTEvent.FOCUS_EVENT_MASK); 3829N/A * public void uninstallUI(JComponent c) { 1910N/A * @param e the {@code FocusEvent} to be processed 1910N/A * @param l the layer this {@code LayerUI} instance is set to 1910N/A * @see JLayer#setLayerEventMask(long) 1910N/A * @see #installUI(javax.swing.JComponent) 1910N/A * @see #uninstallUI(javax.swing.JComponent) 1910N/A * Processes key events occurring on the {@link JLayer} 1910N/A * or any of its subcomponents. 1910N/A * This method is not called unless key events are 1910N/A * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to. 1910N/A * Key events are enabled in the overridden {@link #installUI} method 1910N/A * and should be disabled in the {@link #uninstallUI} method after that. 1910N/A * public void installUI(JComponent c) { 1910N/A * l.setLayerEventMask(AWTEvent.KEY_EVENT_MASK); 3829N/A * public void uninstallUI(JComponent c) { 1910N/A * @param e the {@code KeyEvent} to be processed 1910N/A * @param l the layer this {@code LayerUI} instance is set to 1910N/A * @see JLayer#setLayerEventMask(long) 1910N/A * @see #installUI(javax.swing.JComponent) 1910N/A * @see #uninstallUI(javax.swing.JComponent) 1910N/A * Processes mouse events occurring on the {@link JLayer} 1910N/A * or any of its subcomponents. 1910N/A * This method is not called unless mouse events are 1910N/A * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to. 1910N/A * Mouse events are enabled in the overridden {@link #installUI} method 1910N/A * and should be disabled in the {@link #uninstallUI} method after that. 1910N/A * public void installUI(JComponent c) { 1910N/A * l.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK); 3829N/A * public void uninstallUI(JComponent c) { 1910N/A * @param e the {@code MouseEvent} to be processed 1910N/A * @param l the layer this {@code LayerUI} instance is set to 1910N/A * @see JLayer#setLayerEventMask(long) 1910N/A * @see #installUI(javax.swing.JComponent) 1910N/A * @see #uninstallUI(javax.swing.JComponent) 1910N/A * Processes mouse motion event occurring on the {@link JLayer} 1910N/A * or any of its subcomponents. 1910N/A * This method is not called unless mouse motion events are 1910N/A * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to. 1910N/A * Mouse motion events are enabled in the overridden {@link #installUI} method 1910N/A * and should be disabled in the {@link #uninstallUI} method after that. 1910N/A * public void installUI(JComponent c) { 1910N/A * l.setLayerEventMask(AWTEvent.MOUSE_MOTION_EVENT_MASK); 3829N/A * public void uninstallUI(JComponent c) { 1910N/A * @param e the {@code MouseEvent} to be processed 1910N/A * @param l the layer this {@code LayerUI} instance is set to 1910N/A * @see JLayer#setLayerEventMask(long) 1910N/A * @see #installUI(javax.swing.JComponent) 1910N/A * @see #uninstallUI(javax.swing.JComponent) 1910N/A * Processes mouse wheel event occurring on the {@link JLayer} 1910N/A * or any of its subcomponents. 1910N/A * This method is not called unless mouse wheel events are 1910N/A * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to. 1910N/A * Mouse wheel events are enabled in the overridden {@link #installUI} method 1910N/A * and should be disabled in the {@link #uninstallUI} method after that. 1910N/A * public void installUI(JComponent c) { 1910N/A * l.setLayerEventMask(AWTEvent.MOUSE_WHEEL_EVENT_MASK); 3829N/A * public void uninstallUI(JComponent c) { 1910N/A * @param e the {@code MouseEvent} to be processed 1910N/A * @param l the layer this {@code LayerUI} instance is set to 1910N/A * @see JLayer#setLayerEventMask(long) 1910N/A * @see #installUI(javax.swing.JComponent) 1910N/A * @see #uninstallUI(javax.swing.JComponent) 1910N/A * Processes input event occurring on the {@link JLayer} 1910N/A * or any of its subcomponents. 1910N/A * This method is not called unless input events are 1910N/A * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to. 1910N/A * Input events are enabled in the overridden {@link #installUI} method 1910N/A * and should be disabled in the {@link #uninstallUI} method after that. 1910N/A * public void installUI(JComponent c) { 1910N/A * l.setLayerEventMask(AWTEvent.INPUT_METHOD_EVENT_MASK); 3829N/A * public void uninstallUI(JComponent c) { 1910N/A * @param e the {@code InputMethodEvent} to be processed 1910N/A * @param l the layer this {@code LayerUI} instance is set to 1910N/A * @see JLayer#setLayerEventMask(long) 1910N/A * @see #installUI(javax.swing.JComponent) 1910N/A * @see #uninstallUI(javax.swing.JComponent) 1910N/A * Processes hierarchy event occurring on the {@link JLayer} 1910N/A * or any of its subcomponents. 1910N/A * This method is not called unless hierarchy events are 1910N/A * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to. 1910N/A * Hierarchy events are enabled in the overridden {@link #installUI} method 1910N/A * and should be disabled in the {@link #uninstallUI} method after that. 1910N/A * public void installUI(JComponent c) { 1910N/A * l.setLayerEventMask(AWTEvent.HIERARCHY_EVENT_MASK); 3829N/A * public void uninstallUI(JComponent c) { 1910N/A * @param e the {@code HierarchyEvent} to be processed 1910N/A * @param l the layer this {@code LayerUI} instance is set to 1910N/A * @see JLayer#setLayerEventMask(long) 1910N/A * @see #installUI(javax.swing.JComponent) 1910N/A * @see #uninstallUI(javax.swing.JComponent) 1910N/A * Processes hierarchy bounds event occurring on the {@link JLayer} 1910N/A * or any of its subcomponents. 1910N/A * This method is not called unless hierarchy bounds events are 1910N/A * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to. 1910N/A * Hierarchy bounds events are enabled in the overridden {@link #installUI} 1910N/A * method and should be disabled in the {@link #uninstallUI} method after that. 1910N/A * public void installUI(JComponent c) { 1910N/A * l.setLayerEventMask(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK); 3829N/A * public void uninstallUI(JComponent c) { 1910N/A * @param e the {@code HierarchyEvent} to be processed 1910N/A * @param l the layer this {@code LayerUI} instance is set to 1910N/A * @see JLayer#setLayerEventMask(long) 1910N/A * @see #installUI(javax.swing.JComponent) 1910N/A * @see #uninstallUI(javax.swing.JComponent) 1561N/A * Invoked when {@link javax.swing.JLayer#updateUI()} is called 1561N/A * by the {@code JLayer} this {@code LayerUI} is set to. 1561N/A * @param l the {@code JLayer} which UI is updated 1561N/A * Configures the {@code JLayer} this {@code LayerUI} is set to. 3085N/A * The default implementation registers the passed {@code JLayer} component 3085N/A * as a {@code PropertyChangeListener} for the property changes of this {@code LayerUI}. 1561N/A * @param c the {@code JLayer} component where this UI delegate is being installed 1561N/A * Reverses the configuration which was previously set 1561N/A * in the {@link #installUI(JComponent)} method. 3085N/A * The default implementation unregisters the passed {@code JLayer} component 3085N/A * as a {@code PropertyChangeListener} for the property changes of this {@code LayerUI}. 1561N/A * @param c the component from which this UI delegate is being removed. 1561N/A * Adds a PropertyChangeListener to the listener list. The listener is 1561N/A * registered for all bound properties of this class. 1561N/A * If {@code listener} is {@code null}, 1561N/A * no exception is thrown and no action is performed. 1561N/A * @param listener the property change listener to be added 1561N/A * @see #removePropertyChangeListener 1561N/A * @see #getPropertyChangeListeners 1561N/A * @see #addPropertyChangeListener(String, java.beans.PropertyChangeListener) 1561N/A * Removes a PropertyChangeListener from the listener list. This method 1561N/A * should be used to remove PropertyChangeListeners that were registered 1561N/A * for all bound properties of this class. 1561N/A * If {@code listener} is {@code null}, 1561N/A * no exception is thrown and no action is performed. 1561N/A * @param listener the PropertyChangeListener to be removed 1561N/A * @see #addPropertyChangeListener 1561N/A * @see #getPropertyChangeListeners 1561N/A * @see #removePropertyChangeListener(String, PropertyChangeListener) 1561N/A * Returns an array of all the property change listeners 1561N/A * registered on this component. 1561N/A * @return all of this ui's {@code PropertyChangeListener}s 1561N/A * or an empty array if no property change 1561N/A * listeners are currently registered 1561N/A * @see #addPropertyChangeListener 1561N/A * @see #removePropertyChangeListener 1561N/A * @see #getPropertyChangeListeners(String) 1561N/A * Adds a PropertyChangeListener to the listener list for a specific 1561N/A * If {@code propertyName} or {@code listener} is {@code null}, 1561N/A * no exception is thrown and no action is taken. 1561N/A * @param propertyName one of the property names listed above 1561N/A * @param listener the property change listener to be added 1561N/A * @see #removePropertyChangeListener(String, PropertyChangeListener) 1561N/A * @see #getPropertyChangeListeners(String) 1561N/A * @see #addPropertyChangeListener(String, PropertyChangeListener) 1561N/A * Removes a {@code PropertyChangeListener} from the listener 1561N/A * list for a specific property. This method should be used to remove 1561N/A * {@code PropertyChangeListener}s 1561N/A * that were registered for a specific bound property. 1561N/A * If {@code propertyName} or {@code listener} is {@code null}, 1561N/A * no exception is thrown and no action is taken. 1561N/A * @param propertyName a valid property name 1561N/A * @param listener the PropertyChangeListener to be removed 1561N/A * @see #addPropertyChangeListener(String, PropertyChangeListener) 1561N/A * @see #getPropertyChangeListeners(String) 1561N/A * @see #removePropertyChangeListener(PropertyChangeListener) 1561N/A * Returns an array of all the listeners which have been associated 1636N/A * @param propertyName The name of the property being listened to 1561N/A * @return all of the {@code PropertyChangeListener}s associated with 1561N/A * the named property; if no such listeners have been added or 1561N/A * if {@code propertyName} is {@code null}, an empty 1561N/A * @see #addPropertyChangeListener(String, PropertyChangeListener) 1561N/A * @see #removePropertyChangeListener(String, PropertyChangeListener) 1561N/A * @see #getPropertyChangeListeners 1561N/A * Support for reporting bound property changes for Object properties. 1561N/A * This method can be called when a bound property has changed and it will 1561N/A * send the appropriate PropertyChangeEvent to any registered 1561N/A * @param propertyName the property whose value has changed 1561N/A * @param oldValue the property's previous value 1561N/A * @param newValue the property's new value 1561N/A * Notifies the {@code LayerUI} when any of its property are changed 1910N/A * and enables updating every {@code JLayer} 1910N/A * this {@code LayerUI} instance is set to. 1561N/A * @param evt the PropertyChangeEvent generated by this {@code LayerUI} 1561N/A * @param l the {@code JLayer} this LayerUI is set to 1561N/A * If the {@code JLayer}'s view component is not {@code null}, 1561N/A * this calls the view's {@code getBaseline()} method. 1561N/A * Otherwise, the default implementation is called. 1561N/A * @param c {@code JLayer} to return baseline resize behavior for 1561N/A * @param width the width to get the baseline for 1561N/A * @param height the height to get the baseline for 1561N/A * @return baseline or a value < 0 indicating there is no reasonable 1561N/A * If the {@code JLayer}'s view component is not {@code null}, 2778N/A * this returns the result of the view's {@code getBaselineResizeBehavior()} method. 1561N/A * Otherwise, the default implementation is called. 1561N/A * @param c {@code JLayer} to return baseline resize behavior for 1561N/A * @return an enum indicating how the baseline changes as the component 2778N/A * Causes the passed instance of {@code JLayer} to lay out its components. 2778N/A * @param l the {@code JLayer} component where this UI delegate is being installed 2778N/A * If the {@code JLayer}'s view component is not {@code null}, 2778N/A * this returns the result of the view's {@code getPreferredSize()} method. 2778N/A * Otherwise, the default implementation is used. 2778N/A * @param c {@code JLayer} to return preferred size for 2778N/A * @return preferred size for the passed {@code JLayer} 2778N/A * If the {@code JLayer}'s view component is not {@code null}, 2778N/A * this returns the result of the view's {@code getMinimalSize()} method. 2778N/A * Otherwise, the default implementation is used. 2778N/A * @param c {@code JLayer} to return preferred size for 2778N/A * @return minimal size for the passed {@code JLayer} 2778N/A * If the {@code JLayer}'s view component is not {@code null}, 2778N/A * this returns the result of the view's {@code getMaximumSize()} method. 2778N/A * Otherwise, the default implementation is used. 2778N/A * @param c {@code JLayer} to return preferred size for 3829N/A * @return maximum size for the passed {@code JLayer} 3555N/A * Paints the specified region in the {@code JLayer} this {@code LayerUI} is set to, immediately. 2778N/A * This method is to be overridden when the dirty region needs to be changed. 3555N/A * The default implementation delegates its functionality to {@link JComponent#paintImmediately(int, int, int, int)}. 3555N/A * @param x the x value of the region to be painted 3555N/A * @param y the y value of the region to be painted 3995N/A * @param width the width of the region to be painted 3995N/A * @param height the height of the region to be painted 3555N/A * @see JComponent#paintImmediately(int, int, int, int)