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
JBoxis 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
Nested ClassesModifier and TypeClassDescriptionprotected classThis class implements accessibility support for theJBoxclass.Nested 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
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_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
ConstructorsConstructorDescriptionJBox()Creates a newJBoxwith a double buffer and a flow layout.JBox(boolean isDoubleBuffered) Creates a newJBoxwith the specified buffering strategy qnd a defaultMigLayoutinstance 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.voidThis method is expected to be implemented as follows:voidprotected StringReturns a string representation of this JBox.voidSets the look and feel (L&F) object that renders this component.voidCertain style configurations require SwingTree to install a custom UI delegate.voidupdateUI()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, 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, 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, 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
-
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 newJBoxwith the specified buffering strategy qnd a defaultMigLayoutinstance configured to be without insets and gaps between components. IfisDoubleBufferedis true, theJBoxwill 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 newJBoxwith a double buffer and a flow layout.
-
-
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.- Overrides:
updateUIin classJComponent- See Also:
-
getUI
Returns the look and feel (L&F) object that renders this component.- Overrides:
getUIin 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:
getUIClassIDin 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:
paramStringin 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:
getAccessibleContextin interfaceAccessible- Overrides:
getAccessibleContextin classComponent- Returns:
- an AccessibleJBox that serves as the AccessibleContext of this JBox
-