Package org.jdesktop.swingx
Class JXPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.jdesktop.swingx.JXPanel
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
,javax.swing.Scrollable
- Direct Known Subclasses:
AbstractPatternPanel
,GradientPreviewPanel
,JXCollapsiblePane
,JXGlassBox
,JXGradientChooser
,JXGraph
,JXHeader
,JXImagePanel
,JXImageView
,JXLoginPane
,JXTaskPaneContainer
,JXTipOfTheDay
,JXTitledPanel
,JXTitledSeparator
,WrappingIconPanel
public class JXPanel extends javax.swing.JPanel implements javax.swing.Scrollable
A simple JPanel extension that adds translucency support. This component and all of its content will be displayed with the specified "alpha" transluscency property value. It also supports the Painters using the backgroundPainter property. For example, to change the background of the panel to a checkeboard do something like this:JXPanel panel = new JXPanel(); panel.setBackgroundPainter(new CheckerboardPainter());
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float
getAlpha()
Painter
getBackgroundPainter()
Returns the current background painter.float
getEffectiveAlpha()
Unlike other properties, alpha can be set on a component, or on one of its parents.java.awt.Dimension
getPreferredScrollableViewportSize()
int
getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
boolean
getScrollableTracksViewportHeight()
boolean
getScrollableTracksViewportWidth()
int
getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
boolean
isInheritAlpha()
boolean
isPaintBorderInsets()
Returns true if the background painter should paint where the border is or false if it should only paint inside the border.void
paint(java.awt.Graphics g)
Overriden paint method to take into account the alpha settingprotected void
paintComponent(java.awt.Graphics g)
Overridden to provide Painter support.void
setAlpha(float alpha)
Set the alpha transparency level for this component.void
setBackgroundPainter(Painter p)
Sets a Painter to use to paint the background of this JXPanel.void
setInheritAlpha(boolean val)
void
setPaintBorderInsets(boolean paintBorderInsets)
Sets the paintBorderInsets property.void
setScrollableTracksViewportHeight(boolean scrollableTracksViewportHeight)
void
setScrollableTracksViewportWidth(boolean scrollableTracksViewportWidth)
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, 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, 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, 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, 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, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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, transferFocusUpCycle
-
-
-
-
Constructor Detail
-
JXPanel
public JXPanel()
Creates a new instance of JXPanel
-
JXPanel
public JXPanel(boolean isDoubleBuffered)
- Parameters:
isDoubleBuffered
-
-
JXPanel
public JXPanel(java.awt.LayoutManager layout)
- Parameters:
layout
-
-
JXPanel
public JXPanel(java.awt.LayoutManager layout, boolean isDoubleBuffered)
- Parameters:
layout
-isDoubleBuffered
-
-
-
Method Detail
-
setAlpha
public void setAlpha(float alpha)
Set the alpha transparency level for this component. This automatically causes a repaint of the component.TODO add support for animated changes in translucency
- Parameters:
alpha
- must be a value between 0 and 1 inclusive.
-
getAlpha
public float getAlpha()
- Returns:
- the alpha translucency level for this component. This will be a value between 0 and 1, inclusive.
-
getEffectiveAlpha
public float getEffectiveAlpha()
Unlike other properties, alpha can be set on a component, or on one of its parents. If the alpha of a parent component is .4, and the alpha on this component is .5, effectively the alpha for this component is .4 because the lowest alpha in the heirarchy "wins"
-
isInheritAlpha
public boolean isInheritAlpha()
-
setInheritAlpha
public void setInheritAlpha(boolean val)
-
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()
- Specified by:
getScrollableTracksViewportHeight
in interfacejavax.swing.Scrollable
-
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()
- Specified by:
getScrollableTracksViewportWidth
in interfacejavax.swing.Scrollable
-
getPreferredScrollableViewportSize
public java.awt.Dimension getPreferredScrollableViewportSize()
- Specified by:
getPreferredScrollableViewportSize
in interfacejavax.swing.Scrollable
-
getScrollableBlockIncrement
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
- Specified by:
getScrollableBlockIncrement
in interfacejavax.swing.Scrollable
-
getScrollableUnitIncrement
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
- Specified by:
getScrollableUnitIncrement
in interfacejavax.swing.Scrollable
-
setScrollableTracksViewportHeight
public void setScrollableTracksViewportHeight(boolean scrollableTracksViewportHeight)
- Parameters:
scrollableTracksViewportHeight
- The scrollableTracksViewportHeight to set.
-
setScrollableTracksViewportWidth
public void setScrollableTracksViewportWidth(boolean scrollableTracksViewportWidth)
- Parameters:
scrollableTracksViewportWidth
- The scrollableTracksViewportWidth to set.
-
setBackgroundPainter
public void setBackgroundPainter(Painter p)
Sets a Painter to use to paint the background of this JXPanel. By default a JXPanel already has a single painter installed which draws the normal background for a panel according to the current Look and Feel. CallingsetBackgroundPainter
will replace that existing painter.- Parameters:
p
- the new painter- See Also:
getBackgroundPainter()
-
getBackgroundPainter
public Painter getBackgroundPainter()
Returns the current background painter. The default value of this property is a painter which draws the normal JPanel background according to the current look and feel.- Returns:
- the current painter
- See Also:
setBackgroundPainter(Painter)
,isPaintBorderInsets()
-
isPaintBorderInsets
public boolean isPaintBorderInsets()
Returns true if the background painter should paint where the border is or false if it should only paint inside the border. This property is true by default. This property affects the width, height, and intial transform passed to the background painter.
-
setPaintBorderInsets
public void setPaintBorderInsets(boolean paintBorderInsets)
Sets the paintBorderInsets property. Set to true if the background painter should paint where the border is or false if it should only paint inside the border. This property is true by default. This property affects the width, height, and intial transform passed to the background painter. This is a bound property.
-
paint
public void paint(java.awt.Graphics g)
Overriden paint method to take into account the alpha setting- Overrides:
paint
in classjavax.swing.JComponent
- Parameters:
g
-
-
paintComponent
protected void paintComponent(java.awt.Graphics g)
Overridden to provide Painter support. It will call backgroundPainter.paint() if it is not null, else it will call super.paintComponent().- Overrides:
paintComponent
in classjavax.swing.JComponent
-
-