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:
- GJBasicPanel
@JavaBean public class JXPanel extends javax.swing.JPanel implements javax.swing.Scrollable
An extended
JPanelthat provides additional features.Scrollable
JXPanelisScrollableby default. It provides reasonable implementations of all of the interface methods. In addition, it supports the setting of common scrolling approaches defined inScrollableSizeHint.Alpha Support
JXPanelhas full alpha-channel support. This means that theJXPanelcan be made fully or partially transparent. This means that the JXPanel and all of its children will behave as a single paint at the specified alpha value. Cauton: best practice is to use either alpha support or opacity support, but not both. See the documentation on the methods for further information.A transparency example, this following code will show the black background of the parent:
JXPanel panel = new JXPanel(); panel.add(new JButton("Push Me")); panel.setAlpha(.5f); container.setBackground(Color.BLACK); container.add(panel);Painter Support
JXPanelhas support for Painters.A painter example, this following code will show how to add a simple painter:
JXPanel panel = new JXPanel(); panel.setBackgroundPainter(new PinstripePainter());
- See Also:
Scrollable,Painter, Serialized Form
-
-
Nested Class Summary
-
Field Summary
-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor and Description JXPanel()Creates a newJXPanelwith a double buffer and a flow layout.JXPanel(boolean isDoubleBuffered)Creates a newJXPanelwithFlowLayoutand the specified buffering strategy.JXPanel(java.awt.LayoutManager layout)Create a new buffered JXPanel with the specified layout managerJXPanel(java.awt.LayoutManager layout, boolean isDoubleBuffered)Creates a new JXPanel with the specified layout manager and buffering strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description floatgetAlpha()Get the current alpha value.org.jdesktop.swingx.painter.PaintergetBackgroundPainter()Returns the current background painter.floatgetEffectiveAlpha()Unlike other properties, alpha can be set on a component, or on one of its parents.java.awt.DimensiongetPreferredScrollableViewportSize()intgetScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)booleangetScrollableTracksViewportHeight()booleangetScrollableTracksViewportWidth()intgetScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)booleanisInheritAlpha()Returns the state of the panel with respect to inheriting alpha values.booleanisPaintBorderInsets()Returns true if the background painter should paint where the border is or false if it should only paint inside the border.voidpaint(java.awt.Graphics g)Overridden paint method to take into account the alpha setting.voidsetAlpha(float alpha)Set the alpha transparency level for this component.voidsetBackgroundPainter(org.jdesktop.swingx.painter.Painter p)Sets a Painter to use to paint the background of this JXPanel.voidsetInheritAlpha(boolean val)Determines if the effective alpha of this component should include the alpha of ancestors.voidsetOpaque(boolean opaque)voidsetPaintBorderInsets(boolean paintBorderInsets)Sets the paintBorderInsets property.voidsetScrollableHeightHint(ScrollableSizeHint hint)Sets the vertical sizing hint.voidsetScrollableTracksViewportHeight(boolean scrollableTracksViewportHeight)Sets the vertical size tracking to either ScrollableSizeTrack.FIT or NONE, if the boolean parameter is true or false, respectively.voidsetScrollableTracksViewportWidth(boolean scrollableTracksViewportWidth)Sets the horizontal size tracking to either ScrollableSizeTrack.FIT or NONE, if the boolean parameter is true or false, respectively.voidsetScrollableWidthHint(ScrollableSizeHint hint)Sets the horizontal sizing hint.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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, 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, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Constructor Detail
-
JXPanel
public JXPanel()
Creates a newJXPanelwith a double buffer and a flow layout.
-
JXPanel
public JXPanel(boolean isDoubleBuffered)
Creates a newJXPanelwithFlowLayoutand the specified buffering strategy. IfisDoubleBufferedis true, theJXPanelwill use a double buffer.- Parameters:
isDoubleBuffered- a boolean, true for double-buffering, which uses additional memory space to achieve fast, flicker-free updates
-
JXPanel
public JXPanel(java.awt.LayoutManager layout)
Create a new buffered JXPanel with the specified layout manager- Parameters:
layout- the LayoutManager to use
-
JXPanel
public JXPanel(java.awt.LayoutManager layout, boolean isDoubleBuffered)Creates a new JXPanel with the specified layout manager and buffering strategy.- Parameters:
layout- the LayoutManager to useisDoubleBuffered- a boolean, true for double-buffering, which uses additional memory space to achieve fast, flicker-free updates
-
-
Method Detail
-
setOpaque
public void setOpaque(boolean opaque)
Setting the component to be opaque will reset the alpha setting to
1f(full opaqueness). Setting the component to be non-opaque will restore the previous alpha transparency. If the component is non-opaque with a fully-opaque alpha value (1f), the behavior should be the same as as aJPanelthat is non-opaque.- Overrides:
setOpaquein classjavax.swing.JComponent
-
getAlpha
public float getAlpha()
Get the current alpha value.- Returns:
- the alpha translucency level for this component. This will be a value between 0 and 1, inclusive.
-
setAlpha
public void setAlpha(float alpha)
Set the alpha transparency level for this component. This automatically causes a repaint of the component.- Parameters:
alpha- must 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 hierarchy "wins."- Returns:
- the lowest alpha value in the hierarchy
-
isInheritAlpha
public boolean isInheritAlpha()
Returns the state of the panel with respect to inheriting alpha values.- Returns:
trueif this panel inherits alpha values;falseotherwise- See Also:
setInheritAlpha(boolean)
-
setInheritAlpha
public void setInheritAlpha(boolean val)
Determines if the effective alpha of this component should include the alpha of ancestors.- Parameters:
val-trueto include ancestral alpha data;falseotherwise- See Also:
isInheritAlpha(),getEffectiveAlpha()
-
setScrollableWidthHint
public final void setScrollableWidthHint(ScrollableSizeHint hint)
Sets the horizontal sizing hint. The hint is used by the Scrollable implementation to service the getScrollableTracksWidth.- Parameters:
hint- the horizontal sizing hint, must not be null and must be vertical.- Throws:
java.lang.NullPointerException- if null- See Also:
setScrollableHeightHint(ScrollableSizeHint),ScrollableSizeHint
-
setScrollableHeightHint
public final void setScrollableHeightHint(ScrollableSizeHint hint)
Sets the vertical sizing hint. The hint is used by the Scrollable implementation to service the getScrollableTracksHeight.- Parameters:
hint- the vertical sizing hint, must not be null and must be vertical.- Throws:
java.lang.NullPointerException- if null- See Also:
setScrollableWidthHint(ScrollableSizeHint),ScrollableSizeHint
-
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()
- Specified by:
getScrollableTracksViewportHeightin interfacejavax.swing.Scrollable
-
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()
- Specified by:
getScrollableTracksViewportWidthin interfacejavax.swing.Scrollable
-
getPreferredScrollableViewportSize
public java.awt.Dimension getPreferredScrollableViewportSize()
- Specified by:
getPreferredScrollableViewportSizein interfacejavax.swing.Scrollable
-
getScrollableBlockIncrement
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)- Specified by:
getScrollableBlockIncrementin interfacejavax.swing.Scrollable
-
getScrollableUnitIncrement
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)- Specified by:
getScrollableUnitIncrementin interfacejavax.swing.Scrollable
-
setScrollableTracksViewportHeight
public void setScrollableTracksViewportHeight(boolean scrollableTracksViewportHeight)
Sets the vertical size tracking to either ScrollableSizeTrack.FIT or NONE, if the boolean parameter is true or false, respectively.NOTE: this method is kept for backward compatibility only, for full control use setScrollableHeightHint.
- Parameters:
scrollableTracksViewportHeight- The scrollableTracksViewportHeight to set.- See Also:
setScrollableHeightHint(ScrollableSizeHint)
-
setScrollableTracksViewportWidth
public void setScrollableTracksViewportWidth(boolean scrollableTracksViewportWidth)
Sets the horizontal size tracking to either ScrollableSizeTrack.FIT or NONE, if the boolean parameter is true or false, respectively.NOTE: this method is kept for backward compatibility only, for full control use setScrollableWidthHint.
- Parameters:
scrollableTracksViewportWidth- The scrollableTracksViewportWidth to set.- See Also:
setScrollableWidthHint(ScrollableSizeHint)
-
setBackgroundPainter
public void setBackgroundPainter(org.jdesktop.swingx.painter.Painter p)
Sets a Painter to use to paint the background of this JXPanel.- Parameters:
p- the new painter- See Also:
getBackgroundPainter()
-
getBackgroundPainter
public org.jdesktop.swingx.painter.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 initial transform passed to the background painter.- Returns:
trueto paint under the border;falseotherwise
-
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 initial transform passed to the background painter. This is a bound property.
-
paint
public void paint(java.awt.Graphics g)
Overridden paint method to take into account the alpha setting.- Overrides:
paintin classjavax.swing.JComponent- Parameters:
g- theGraphicscontext in which to paint
-
-
DMelt 3.0 © DataMelt by jWork.ORG