public final class ViewGroup
extends javax.swing.JPanel
View
s or other JComponent
s.
setWeights(float[])
you can set the weights of size in percent for the components they should occupy in the group.
E.g. you have two components and set the weights to 0.3 for component 1 and 0.7 to component 2. That means component 1 has 30% of the size
the group has and component 2 has 70%. If the group is resized (for example because the window is resized) the sizes of the components
were adjusted to the new size of the group.getWeights()
to get the current weights of the components in the group.storeWeights(Serializer, String)
and restoreWeights(Serializer, String, float[])
to serialize and deserialize
the current weights of the group.
Container.add(Component)
.View
,
Serialized Formjavax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static int |
HORIZONTAL
the orientation of the components is horizontal
|
static int |
VERTICAL
the orientation of the components is vertical
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
ViewGroup(int orientation)
Creates a new group.
|
ViewGroup(int orientation,
int padding)
Creates a new group.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addImpl(java.awt.Component c,
java.lang.Object constraints,
int index) |
void |
doLayout()
Does the layout of the view group meaning the views and sub groups are arranged.
|
int |
getOrientation()
Gets the orientation of the group.
|
float[] |
getWeights()
Gets the current weights of the components in this group.
|
void |
remove(int index)
Removes a component from the view group.
|
void |
restoreWeights(Serializer s,
java.lang.String key,
float[] def)
Restores the weights of the components.
|
void |
setBorder(javax.swing.border.Border b)
The border of a view group may not be changed meaning this method does nothing!
|
void |
setCursor(java.awt.Cursor c)
The cursor of a view group may not be changed meaning this method does nothing!
|
void |
setLayout(java.awt.LayoutManager mgr)
The layout of a view group may not be changed meaning this method does nothing!
|
void |
setWeights(float[] weights)
Sets the weights of the components in this group.
|
void |
storeWeights(Serializer s,
java.lang.String key)
Stores the current weights of the components in the specified
Serializer . |
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, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, 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, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final int HORIZONTAL
public static final int VERTICAL
public ViewGroup(int orientation) throws java.lang.IllegalArgumentException
orientation
- the orientation of the components which could be HORIZONTAL
or VERTICAL
java.lang.IllegalArgumentException
- HORIZONTAL
or VERTICAL
public ViewGroup(int orientation, int padding) throws java.lang.IllegalArgumentException
orientation
- the orientation of the components which could be HORIZONTAL
or VERTICAL
padding
- the free space between the border of the group and the inner componentsjava.lang.IllegalArgumentException
- HORIZONTAL
or VERTICAL
public int getOrientation()
HORIZONTAL
,
VERTICAL
public float[] getWeights()
public void setWeights(float[] weights) throws java.lang.IllegalArgumentException
weights
- the weights (the sum of the weights must be 1 and the array must have the length of the number of components that this group has)java.lang.IllegalArgumentException
- 1.0f
public void setLayout(java.awt.LayoutManager mgr)
setLayout
in class java.awt.Container
mgr
- the layout managerpublic void storeWeights(Serializer s, java.lang.String key) throws java.lang.IllegalArgumentException
Serializer
.s
- the serializerkey
- the data keyjava.lang.IllegalArgumentException
- public void restoreWeights(Serializer s, java.lang.String key, float[] def) throws java.lang.IllegalArgumentException
s
- the serializer that contains the weightskey
- the data keydef
- the default weightsjava.lang.IllegalArgumentException
- 1.0f
public void setCursor(java.awt.Cursor c)
setCursor
in class java.awt.Component
c
- the cursorpublic void setBorder(javax.swing.border.Border b)
setBorder
in class javax.swing.JComponent
b
- the borderpublic void doLayout()
doLayout
in class java.awt.Container
public void remove(int index)
remove
in class java.awt.Container
index
- the index of the component that should be removedprotected void addImpl(java.awt.Component c, java.lang.Object constraints, int index)
addImpl
in class java.awt.Container