public class OptionsPanel extends JPanel
Options
uses this for
laying out components.Modifier and Type | Class and Description |
---|---|
static class |
OptionsPanel.RoundedLineBorder
The border used for boxes when
beginBorderedGroup(String, boolean) . |
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
OptionsPanel()
Calls
OptionsPanel(true, true) . |
OptionsPanel(boolean inScrollPane,
boolean centerLayout) |
Modifier and Type | Method and Description |
---|---|
void |
addComponent(JComponent component,
boolean fillRightHandSpace)
Add a component without a label.
|
void |
addComponentWithLabel(JLabel label,
JComponent component,
boolean componentFillsRightHandSpace)
Add a component with a label.
|
JLabel |
addComponentWithLabel(String label,
JComponent component,
boolean componentFillsRightHandSpace)
Add a component with a label.
|
void |
addDivider()
Add a 1 pixel high, gray horizontal line which divides the components vertically.
|
JLabel |
addDividerWithLabel(String label)
Add a 1 pixel high, gray horizontal line which divides the components vertically.
|
void |
addGap()
Add an empty component which will introduce a space between the last and next component.
|
void |
addSpanningComponent(JComponent component)
Add a component which fills the entire width of the panel.
|
void |
addSpanningComponent(JComponent component,
boolean fillHorizontalSpace,
int anchor)
Add a component which spans both the label and component areas.
|
void |
addSpanningComponent(JComponent component,
boolean fillHorizontalSpace,
int anchor,
double weighty)
Add a component which spans both the label and component areas.
|
void |
addTwoComponents(JComponent leftComponent,
JComponent rightComponent,
boolean fillLeftHandSpace,
boolean fillRightHandSpace)
Add two components, one is instead of the label on the left.
|
void |
addWeightedGap(double weightY)
Add a gap that takes up aany additional vertical space available.
|
void |
beginBorderedGroup(String label,
boolean headless)
Subsequent components will be added inside a bordered sub panel.
|
void |
endBorderedGroup()
If we are adding components to a sub panel (see
beginBorderedGroup(String, boolean) ), then close off the current
sub panel. |
void |
removeAll() |
void |
setComponentPosition(int anchor)
Set where the components
(or right component in the case of
addTwoComponents(javax.swing.JComponent, javax.swing.JComponent, boolean, boolean)
are positioned (normally EAST, WEST or CENTER). |
void |
setHorizontallyCompact(boolean compact)
Set whether this panel should layout its componets in a visually compact form suitable for displaying in a limited amount of space.
|
void |
setLabelPosition(int anchor)
Set where the labels
(or left component in the case of
addTwoComponents(javax.swing.JComponent, javax.swing.JComponent, boolean, boolean)
are positioned (normally EAST, WEST or CENTER). |
void |
setVerticalSpacing(int spacingBelow)
Deprecated.
use
setVerticalSpacing(int, int) instead |
void |
setVerticalSpacing(int spacingAbove,
int spacingBelow)
Sets the spacing above and below added componenents.
|
void |
setWeightY(double weightY)
Set the vertical weight of components added using methods that don't take weightY as a parameter.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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
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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
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, transferFocusBackward, transferFocusUpCycle
public OptionsPanel()
OptionsPanel(true, true)
.public OptionsPanel(boolean inScrollPane, boolean centerLayout)
inScrollPane
- true to have all the components placed inside a scroll pane.centerLayout
- true so that the labels have equal width to the components, centering the divide between the labels and components.
if false, the labels only use as much space as required.@Deprecated public void setVerticalSpacing(int spacingBelow)
setVerticalSpacing(int, int)
insteadspacingBelow
- new spacing in pixelspublic void setVerticalSpacing(int spacingAbove, int spacingBelow)
spacingAbove
- new spacing above added components (in pixels)spacingBelow
- new spacing below added components (in pixels)public void addComponent(JComponent component, boolean fillRightHandSpace)
component
- component to addfillRightHandSpace
- true to make the component expand to use all space to the right of the labels. False to
make it left aligned in the space to the right of the labels, at its preferred size.addSpanningComponent(javax.swing.JComponent)
,
addSpanningComponent(javax.swing.JComponent, boolean, int)
public JLabel addComponentWithLabel(String label, JComponent component, boolean componentFillsRightHandSpace)
label
- label to add, will be right aligned within the space to the left of the components.component
- component to addcomponentFillsRightHandSpace
- true to make the component expand to use all space to the right of the labels. False to
make it left aligned in the space to the right of the labels, at its preferred size.public void addComponentWithLabel(JLabel label, JComponent component, boolean componentFillsRightHandSpace)
label
- label to add, will be right aligned within the space to the left of the components.component
- component to addcomponentFillsRightHandSpace
- true to make the component expand to use all space to the right of the labels. False to
make it left aligned in the space to the right of the labels, at its preferred size.public void addSpanningComponent(JComponent component)
component
- component to addpublic void addSpanningComponent(JComponent component, boolean fillHorizontalSpace, int anchor)
component
- component to add.fillHorizontalSpace
- true so that the component is expanded to fill the entire width of the panel, false to
use its preferred size and the specified anchor position (below)anchor
- where the component should be placed if fillHorizontalSpace is false. eg. GridBagConstraints.WEST,
GridBagConstraints.CENTERGridBagConstraints.anchor
public void addSpanningComponent(JComponent component, boolean fillHorizontalSpace, int anchor, double weighty)
component
- component to add.fillHorizontalSpace
- true so that the component is expanded to fill the entire width of the panel, false to
use its preferred size and the specified anchor position (below)anchor
- where the component should be placed if fillHorizontalSpace is false. eg. GridBagConstraints.WEST,
GridBagConstraints.CENTERweighty
- see {@link java.awt.GridBagConstraints#weightyGridBagConstraints.anchor
public void setWeightY(double weightY)
weightY
- the vertical weight of any components added using methods that don't take weightY as a parameterGridBagConstraints.weighty
public void addDivider()
public JLabel addDividerWithLabel(String label)
label
- text to use for the labelpublic void addGap()
public void addWeightedGap(double weightY)
weightY
- weight of the gap (see above)public void addTwoComponents(JComponent leftComponent, JComponent rightComponent, boolean fillLeftHandSpace, boolean fillRightHandSpace)
leftComponent
- component to add instead of a labelrightComponent
- component to add to the right of the other componentfillLeftHandSpace
- true to make the left component expand to use all space to the left of the other component. False to
make it right aligned in the space to the left of the other component, at its preferred size.fillRightHandSpace
- true to make the right component expand to use all space to the right of the other component. False to
make it left aligned in the space to the right of the other component, at its preferred size.public void setLabelPosition(int anchor)
addTwoComponents(javax.swing.JComponent, javax.swing.JComponent, boolean, boolean)
are positioned (normally EAST, WEST or CENTER).
default GridBagConstraints.EAST
Only applies to labels added after calling this method.anchor
- the position of labels/left hand components. Eg. GridBagConstraints.WEST,
GridBagConstraints.CENTERGridBagConstraints.anchor
public void setComponentPosition(int anchor)
addTwoComponents(javax.swing.JComponent, javax.swing.JComponent, boolean, boolean)
are positioned (normally EAST, WEST or CENTER).
default GridBagConstraints.WEST
Only applies to components added after calling this method.anchor
- the position of right hand components. Eg. GridBagConstraints.WEST,
GridBagConstraints.CENTERGridBagConstraints.anchor
public void beginBorderedGroup(String label, boolean headless)
endBorderedGroup()
to close off the current sub panel.label
- If this is non-null, the border will have a label on its top-left edgeheadless
- if true, the border will not draw its top line (or label if applicable).endBorderedGroup()
public void endBorderedGroup()
beginBorderedGroup(String, boolean)
), then close off the current
sub panel.public void setHorizontallyCompact(boolean compact)
compact
- true to cause this panel to layout its componets in a visually compact form suitable for displaying in a limited amount of space.