Package swingtree.components
Class JGlassPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
swingtree.components.JGlassPane
- All Implemented Interfaces:
AWTEventListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,StylableComponent
A more advanced glass pane implementation than the default Swing
glass pane of a
JRootPane object (A regular JPanel.
In contrast to the default glass pane (JPanel) of a JRootPane,
this pane handles any mouse events, without interrupting the controls underneath
the glass pane (in the content pane of the root pane).
Also, cursors are handled as if the glass pane was invisible
(if no cursor gets explicitly set to the glass pane).- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddMouseListener(MouseListener listener) final voidaddMouseMotionListener(MouseMotionListener listener) final voidaddMouseWheelListener(MouseWheelListener listener) protected voidattachToRootPane(JRootPane rootPane) Marries this glass pane to the suppliedJRootPaneobject and detaches it from the previous root pane using thedetachFromRootPane(JRootPane)method, if a previous root pane was attached.booleancontains(int x, int y) If someone sets a new cursor to the GlassPane we expect that they know what they are doing and return the super.contains(x,y) otherwise we return false to respect the cursors for the underneath componentsprotected voiddetachFromRootPane(@Nullable JRootPane rootPane) Detaches this glass pane from the suppliedJRootPaneobject, if theJRootPane.getGlassPane()method returns this glass pane.voideventDispatched(AWTEvent event) final MouseListener[]final MouseMotionListener[]final MouseWheelListener[]voidThis method is expected to be implemented as follows:voidfinal voidremoveMouseListener(MouseListener listener) final voidremoveMouseMotionListener(MouseMotionListener listener) final voidremoveMouseWheelListener(MouseWheelListener listener) voidCertain style configurations require SwingTree to install a custom UI delegate.voidtoRootPane(@Nullable JRootPane pane) Marries this glass pane to aJRootPaneobject.voidupdateUI()Resets the UI property with a value from the current look and feel.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMousePosition, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface swingtree.style.StylableComponent
paint, paintBackground, paintForeground
-
Field Details
-
rootPane
-
-
Constructor Details
-
JGlassPane
public JGlassPane() -
JGlassPane
-
-
Method Details
-
paintComponent
- Overrides:
paintComponentin classJComponent
-
paintChildren
This method is expected to be implemented as follows:@Override public void paintChildren(Graphics g){ paintForeground(g, ()->super.paintChildren(g)); }- Specified by:
paintChildrenin interfaceStylableComponent- Overrides:
paintChildrenin classJComponent- Parameters:
g- the graphics context to paint on, obtained from the component'sJComponent::paintChildren(Graphics)method.
-
setUISilently
Description copied from interface:StylableComponentCertain style configurations require SwingTree to install a custom UI delegate. This method is used to set the UI delegate for the component but without triggering side effects like the former UI being uninstalled (which itself can cause a lot of undesired side effects).This method is not intended to be called by client code! It exists for internal use only and unfortunately cannot be protected or private due to the nature of the Swing API.
The implementation of this method is expected to look like this:
@Override public void setUISilently(ComponentUI ui){ this.ui = ui; // no side effects }- Specified by:
setUISilentlyin interfaceStylableComponent- Parameters:
ui- the UI delegate to set for the component without triggering side effects.
-
updateUI
public void updateUI()Resets the UI property with a value from the current look and feel. -
attachToRootPane
Marries this glass pane to the suppliedJRootPaneobject and detaches it from the previous root pane using thedetachFromRootPane(JRootPane)method, if a previous root pane was attached.- Parameters:
rootPane- TheJRootPaneobject to which this glass pane should be attached.
-
detachFromRootPane
Detaches this glass pane from the suppliedJRootPaneobject, if theJRootPane.getGlassPane()method returns this glass pane.- Parameters:
rootPane- TheJRootPaneobject from which this glass pane should be detached.
-
toRootPane
Marries this glass pane to aJRootPaneobject. Note that it is expected that the suppliedJRootPaneis the same root pane that this current glass pane is attached to. If the suppliedJRootPaneisnull, then this glass pane is detached from the current root pane.- Parameters:
pane- TheJRootPaneobject to which this glass pane should be attached.
-
getMouseListeners
- Overrides:
getMouseListenersin classComponent
-
addMouseListener
- Overrides:
addMouseListenerin classComponent
-
removeMouseListener
- Overrides:
removeMouseListenerin classComponent
-
getMouseMotionListeners
- Overrides:
getMouseMotionListenersin classComponent
-
addMouseMotionListener
- Overrides:
addMouseMotionListenerin classComponent
-
removeMouseMotionListener
- Overrides:
removeMouseMotionListenerin classComponent
-
getMouseWheelListeners
- Overrides:
getMouseWheelListenersin classComponent
-
addMouseWheelListener
- Overrides:
addMouseWheelListenerin classComponent
-
removeMouseWheelListener
- Overrides:
removeMouseWheelListenerin classComponent
-
eventDispatched
- Specified by:
eventDispatchedin interfaceAWTEventListener
-
contains
public boolean contains(int x, int y) If someone sets a new cursor to the GlassPane we expect that they know what they are doing and return the super.contains(x,y) otherwise we return false to respect the cursors for the underneath components- Overrides:
containsin classJComponent
-