Package swingtree.components
Class JBox
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
swingtree.components.JBox
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,StylableComponent
- Direct Known Subclasses:
JScrollPanels.EntryPanel
,UI.Box
JBox
is a generic lightweight container similar to
javax.swing.JPanel
, but with 2 important differences:
-
The
JBox
is transparent by default, meaning that it does not paint its background if it is not explicitly set through the style API. - It does not have any insets by default.
JBox
type is in no way related to the BoxLayout
!
The term box is referring to the purpose of this component, which
is to tightly store and wrap other sub-components seamlessly...- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
This class implements accessibility support for theJBox
class.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
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
Fields inherited from class java.awt.Component
accessibleContext, 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
ConstructorDescriptionJBox()
Creates a newJBox
with a double buffer and a flow layout.JBox
(boolean isDoubleBuffered) Creates a newJBox
with the specified buffering strategy qnd a defaultMigLayout
instance configured to be without insets and gaps between components.JBox
(LayoutManager layout) Create a new buffered JBox with the specified layout managerJBox
(LayoutManager layout, boolean isDoubleBuffered) Creates a new JBox with the specified layout manager and buffering strategy. -
Method Summary
Modifier and TypeMethodDescriptionGets the AccessibleContext associated with this JBox.getUI()
Returns the look and feel (L&F) object that renders this component.Returns a string that specifies the name of the L&F class that renders this component.void
This method is expected to be implemented as follows within a component extension which ought to be made compatible with SwingTree.void
This method is expected to be implemented as follows:protected String
Returns a string representation of this JBox.void
Sets the look and feel (L&F) object that renders this component.void
Certain style configurations require SwingTree to install a custom UI delegate.void
updateUI()
Resets the UI property with a value from the current look and feel.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, paintComponent, 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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface swingtree.style.StylableComponent
paintBackground, paintForeground
-
Constructor Details
-
JBox
Creates a new JBox 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
-
JBox
Create a new buffered JBox with the specified layout manager- Parameters:
layout
- the LayoutManager to use
-
JBox
public JBox(boolean isDoubleBuffered) Creates a newJBox
with the specified buffering strategy qnd a defaultMigLayout
instance configured to be without insets and gaps between components. IfisDoubleBuffered
is true, theJBox
will use a double buffer.- Parameters:
isDoubleBuffered
- a boolean, true for double-buffering, which uses additional memory space to achieve fast, flicker-free updates
-
JBox
public JBox()Creates a newJBox
with a double buffer and a flow layout.
-
-
Method Details
-
paint
This method is expected to be implemented as follows within a component extension which ought to be made compatible with SwingTree.@Override public void paint(Graphics g){ paintBackground(g, ()->super.paint(g)); }
- Specified by:
paint
in interfaceStylableComponent
- Overrides:
paint
in classJComponent
- Parameters:
g
- the graphics context to paint on, obtained from the component'sJComponent.paint(Graphics)
method.
-
paintChildren
This method is expected to be implemented as follows:@Override public void paintChildren(Graphics g){ paintForeground(g, ()->super.paintChildren(g)); }
- Specified by:
paintChildren
in interfaceStylableComponent
- Overrides:
paintChildren
in classJComponent
- Parameters:
g
- the graphics context to paint on, obtained from the component'sJComponent::paintChildren(Graphics)
method.
-
setUISilently
Description copied from interface:StylableComponent
Certain 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:
setUISilently
in 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.- Overrides:
updateUI
in classJComponent
- See Also:
-
getUI
Returns the look and feel (L&F) object that renders this component.- Overrides:
getUI
in classJComponent
- Returns:
- the PanelUI object that renders this component
-
setUI
Sets the look and feel (L&F) object that renders this component.- Parameters:
ui
- the PanelUI L&F object- See Also:
-
getUIClassID
Returns a string that specifies the name of the L&F class that renders this component.- Overrides:
getUIClassID
in classJComponent
- Returns:
- "PanelUI"
- See Also:
-
paramString
Returns a string representation of this JBox. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
.- Overrides:
paramString
in classJComponent
- Returns:
- a string representation of this JBox.
-
getAccessibleContext
Gets the AccessibleContext associated with this JBox. For the JBox, the AccessibleContext takes the form of an AccessibleJBox. A new AccessibleJBox instance is created if necessary.- Specified by:
getAccessibleContext
in interfaceAccessible
- Overrides:
getAccessibleContext
in classComponent
- Returns:
- an AccessibleJBox that serves as the AccessibleContext of this JBox
-