Package de.sciss.gui
Class SpringPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- de.sciss.gui.SpringPanel
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible
- Direct Known Subclasses:
AudioFileFormatPane,PathField
public class SpringPanel extends javax.swing.JPanelA subclass ofJPanelthat is linked to aSpringLayout. Components must be added using one of thegridAddmethods which define the component's space in terms of a virtual grid. When all components have been added, the actual layout contraints are calculated by calling eithermakeGrid(for equal cell size grid) ormakeCompactGrid. Just likeGridBagLayout, the grid positions need not be "compact", i.e. you may omit complete columns or rows and start at an arbitrary offset.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSpringPanel.ComponentHeightRatioSpringstatic classSpringPanel.ComponentWidthRatioSpringstatic classSpringPanel.RatioSpring-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
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
-
-
Constructor Summary
Constructors Constructor Description SpringPanel()Creates a new panel with zero padding and offsetSpringPanel(int initialX, int initialY, int xPad, int yPad)Creates a new panel with given padding and offset (in pixels).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidgridAdd(javax.swing.JComponent c, int x, int y)Add a component to the panel and store its placement information for use in makeGrid.voidgridAdd(javax.swing.JComponent c, int x, int y, int width, int height)Add a component to the panel and store its placement information for use in makeGrid.voidgridAdd(javax.swing.JComponent c, java.awt.Rectangle r)Add a component to the panel and store its placement information for use in makeGrid.voidmakeCompactGrid()Aligns all the gadgets in a compact grid whose virtual cells are as small as possible (calculated from the maximum width of a column and maximum height of a row).voidmakeCompactGrid(boolean hElastic, boolean vElastic)Aligns all the gadgets in a compact grid whose virtual cells are as small as possible (calculated from the maximum width of a column and maximum height of a row).voidmakeGrid(boolean elastic)Aligns all the gadgets in a regular grid whose virtual cells are all of the same size (calculated from the maximum dimensions of all cells).voidsetInitialX(int x)Changes the horizontal offset.voidsetInitialY(int y)Changes the vertical offset.voidsetPadding(int initialX, int initialY, int xPad, int yPad)Changes the padding and offset for the panel.voidsetTitle(java.lang.String title)Adds a titled border to the panel.voidsetXPad(int x)Changes the horizontal padding.voidsetYPad(int y)Changes the vertical padding.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
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, 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
-
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
-
-
-
-
Constructor Detail
-
SpringPanel
public SpringPanel()
Creates a new panel with zero padding and offset
-
SpringPanel
public SpringPanel(int initialX, int initialY, int xPad, int yPad)Creates a new panel with given padding and offset (in pixels).- Parameters:
initialX- the spacing for gadgets from the left border of the panelinitialY- the spacing for gadgets from the top border of the panelxPad- the spacing between a gadget and its horizontal neighbouryPad- the spacing between a gadget and its vertical neighbour
-
-
Method Detail
-
setInitialX
public void setInitialX(int x)
Changes the horizontal offset. This takes effect, next time makeGrid is called.- Parameters:
x- the spacing for gadgets from the left border of the panel
-
setInitialY
public void setInitialY(int y)
Changes the vertical offset. This takes effect, next time makeGrid is called.- Parameters:
y- the spacing for gadgets from the top border of the panel
-
setXPad
public void setXPad(int x)
Changes the horizontal padding. This takes effect, next time makeGrid is called.- Parameters:
x- the spacing between a gadget and its horizontal neighbour
-
setYPad
public void setYPad(int y)
Changes the vertical padding. This takes effect, next time makeGrid is called.- Parameters:
y- the spacing between a gadget and its vertical neighbour
-
setPadding
public void setPadding(int initialX, int initialY, int xPad, int yPad)Changes the padding and offset for the panel. These take effect, next time makeGrid is called.- Parameters:
initialX- the spacing for gadgets from the left border of the panelinitialY- the spacing for gadgets from the top border of the panelxPad- the spacing between a gadget and its horizontal neighbouryPad- the spacing between a gadget and its vertical neighbour
-
gridAdd
public void gridAdd(javax.swing.JComponent c, int x, int y)Add a component to the panel and store its placement information for use in makeGrid. The component is assumed to occupy a grid dimension of 1 x 1 cell.- Parameters:
c- the componentx- the horizontal grid positiony- the vertical grid position
-
gridAdd
public void gridAdd(javax.swing.JComponent c, int x, int y, int width, int height)Add a component to the panel and store its placement information for use in makeGrid.- Parameters:
c- the componentx- the horizontal grid positiony- the vertical grid positionwidth- the number of columns to occupy (a negative width means the width is not elastic)height- the number of rows to occupy (a negative height means the height is not elastic)
-
gridAdd
public void gridAdd(javax.swing.JComponent c, java.awt.Rectangle r)Add a component to the panel and store its placement information for use in makeGrid.- Parameters:
c- the componentr- the grid location and extent. (a negative width or height means the width or height is not elastic)
-
setTitle
public void setTitle(java.lang.String title)
Adds a titled border to the panel.- Parameters:
title- the text to display in the titled border
-
makeGrid
public void makeGrid(boolean elastic)
Aligns all the gadgets in a regular grid whose virtual cells are all of the same size (calculated from the maximum dimensions of all cells).- Parameters:
elastic- not yet fully working, has to be false for now(?)
-
makeCompactGrid
public void makeCompactGrid()
Aligns all the gadgets in a compact grid whose virtual cells are as small as possible (calculated from the maximum width of a column and maximum height of a row). The layout is automatically stretched when the panel is resized.
-
makeCompactGrid
public void makeCompactGrid(boolean hElastic, boolean vElastic)Aligns all the gadgets in a compact grid whose virtual cells are as small as possible (calculated from the maximum width of a column and maximum height of a row).- Parameters:
hElastic- whether the layout should be horizontally stretched as to use additional space when the panel is horizontally resizedvElastic- whether the layout should be vertically stretched as to use additional space when the panel is vertically resized
-
-