org.tbee.swing.glasspane
Class GlassPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.tbee.swing.glasspane.GlassPane
All Implemented Interfaces:
AWTEventListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible

public class GlassPane
extends JPanel
implements AWTEventListener, PropertyChangeListener

This class can be added as glasspane (setGlassPane) or using the JLayeredPane. Use to visually overlay a frame's contents and optionally (default true) blocks all interaction. Inspired by "A well-behaved GlassPane" http://weblogs.java.net/blog/alexfromsun/

Version:
$Revision: 1.18 $
Author:
Alexander Potochkin
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  TexturePaint iTexturePaint
           
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GlassPane(JApplet applet)
           
GlassPane(JApplet applet, boolean block)
           
GlassPane(JApplet applet, boolean block, boolean draw)
           
GlassPane(JFrame frame)
           
GlassPane(JFrame frame, boolean block)
           
GlassPane(JFrame frame, boolean block, boolean draw)
           
 
Method Summary
static GlassPane addAsGlassPane(JFrame frame, boolean block)
          Add as glasspane
static GlassPane addToLayer(JApplet frame, boolean block)
          Add as layer
static GlassPane addToLayer(JApplet applet, boolean block, int layer)
          Add as layer
static GlassPane addToLayer(JFrame frame, boolean block)
          Add as layer
static GlassPane addToLayer(JFrame frame, boolean block, int layer)
          Add as layer
 void attachAsGlassPane()
          Add as glasspane
 void attachToLayer()
          Add as layer
 void attachToLayer(int layer)
          Add as layer
 boolean contains(int x, int y)
          If someone adds a mouseListener to the GlassPane or set a new cursor we expect that he knows what he is doing and return the super.contains(x, y) otherwise we return false to respect the cursors for the underneath components
 void detach()
          Remove from glasspane and layered pane
 void eventDispatched(AWTEvent event)
          for determining when the mous is over the titlebar icons
 Container getAssociatedContainer()
           
 boolean getDraw()
           
protected  void paintComponent(Graphics g)
           
 void propertyChange(PropertyChangeEvent evt)
           
 void setAssociatedContainer(Container value)
           
 void setDraw(boolean value)
           
 void setPoint(Point point)
          Point
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, update
 
Methods 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, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, 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, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

iTexturePaint

protected TexturePaint iTexturePaint
Constructor Detail

GlassPane

public GlassPane(JFrame frame)
Parameters:
frame -

GlassPane

public GlassPane(JFrame frame,
                 boolean block)
Parameters:
frame -
block -

GlassPane

public GlassPane(JFrame frame,
                 boolean block,
                 boolean draw)
Parameters:
frame -
block -

GlassPane

public GlassPane(JApplet applet)
Parameters:
applet -

GlassPane

public GlassPane(JApplet applet,
                 boolean block)
Parameters:
applet -
block -

GlassPane

public GlassPane(JApplet applet,
                 boolean block,
                 boolean draw)
Parameters:
applet -
block -
Method Detail

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

getDraw

public boolean getDraw()
Returns:
returns Draw.

setDraw

public void setDraw(boolean value)

getAssociatedContainer

public Container getAssociatedContainer()
Returns:
returns AssociatedContainer.

setAssociatedContainer

public void setAssociatedContainer(Container value)

attachAsGlassPane

public void attachAsGlassPane()
Add as glasspane


attachToLayer

public void attachToLayer(int layer)
Add as layer

Parameters:
layer -

attachToLayer

public void attachToLayer()
Add as layer


detach

public void detach()
Remove from glasspane and layered pane


setPoint

public void setPoint(Point point)
Point


paintComponent

protected void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent

eventDispatched

public void eventDispatched(AWTEvent event)
for determining when the mous is over the titlebar icons

Specified by:
eventDispatched in interface AWTEventListener

contains

public boolean contains(int x,
                        int y)
If someone adds a mouseListener to the GlassPane or set a new cursor we expect that he knows what he is doing and return the super.contains(x, y) otherwise we return false to respect the cursors for the underneath components

Overrides:
contains in class JComponent

addAsGlassPane

public static GlassPane addAsGlassPane(JFrame frame,
                                       boolean block)
Add as glasspane

Parameters:
frame -
block -

addToLayer

public static GlassPane addToLayer(JFrame frame,
                                   boolean block,
                                   int layer)
Add as layer

Parameters:
frame -
block -
layer -

addToLayer

public static GlassPane addToLayer(JApplet applet,
                                   boolean block,
                                   int layer)
Add as layer

Parameters:
applet -
block -
layer -

addToLayer

public static GlassPane addToLayer(JFrame frame,
                                   boolean block)
Add as layer

Parameters:
frame -
block -

addToLayer

public static GlassPane addToLayer(JApplet frame,
                                   boolean block)
Add as layer

Parameters:
frame -
block -


Copyright © 2011 KnowledgePlaza. All Rights Reserved.