HiRISE

HiRISE.HiPlan.HiWeb
Class GridBagPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by HiRISE.HiPlan.HiWeb.GridBagPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class GridBagPanel
extends JPanel

A JPanel with a GridBagLayout and utility methods to add and constrain components easily. Conceptually, this is very similar to an HTML Table, where a table cell can span multiple rows and/or columns. In addition, the Anchor (alignment) and fill (expansion) can be specified for a component.

Version:
1.6
Author:
Guy McArthur - UA/PIRL
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
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
static int DEFAULT_ANCHOR
          By default, anchor to the left
static int DEFAULT_FILL
          By default, fill horizontally, not vertically
static Insets DEFAULT_INSETS
          By default, 1 pixel of margin surrounding component
static int DEFAULT_PADDING_X
          Default padding on X axis
static int DEFAULT_PADDING_Y
          Default padding on Y axis
static double DEFAULT_WEIGHT_X
          Default weight on X axis
static double DEFAULT_WEIGHT_Y
          Default weight on Y axis
static String ID
          Class identification name with source code version and date.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
GridBagPanel()
          Create a new GridBagPanel.
 
Method Summary
 void add(Component component, int row, int col)
          Add a component to the Panel, constraining it with the given parameters.
 void add(Component component, int row, int col, int anchor)
          Add a component to the Panel, constraining it with the given parameters.
 void add(Component component, int row, int col, int rspan, int cspan)
          Add a component to the Panel, constraining it with the given parameters.
 void add(Component component, int row, int col, int rspan, int cspan, int anchor, int fill)
          Add a component to the Panel, constraining it with the given parameters.
 void add(Component component, int row, int col, int rspan, int cspan, int anchor, int fill, double wx, double wy)
          Add a component to the Panel, constraining it with the given parameters.
 void add(Component component, int row, int col, int rspan, int cspan, int anchor, int fill, double wx, double wy, int padx, int pady)
          Add a component to the Panel, constraining it with the given parameters.
 void add(Component component, int row, int col, int rspan, int cspan, int anchor, int fill, double wx, double wy, int padx, int pady, Insets insets)
          Add a component to the Panel, constraining it with the given parameters.
 Dimension getMaximumSize()
          Get the maximum size of the component.
 Dimension getPreferredSize()
          Get the preferred size of the component.
 
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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, transferFocusBackward, 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, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values

DEFAULT_ANCHOR

public static final int DEFAULT_ANCHOR
By default, anchor to the left

See Also:
Constant Field Values

DEFAULT_FILL

public static final int DEFAULT_FILL
By default, fill horizontally, not vertically

See Also:
Constant Field Values

DEFAULT_WEIGHT_X

public static final double DEFAULT_WEIGHT_X
Default weight on X axis

See Also:
Constant Field Values

DEFAULT_WEIGHT_Y

public static final double DEFAULT_WEIGHT_Y
Default weight on Y axis

See Also:
Constant Field Values

DEFAULT_PADDING_X

public static final int DEFAULT_PADDING_X
Default padding on X axis

See Also:
Constant Field Values

DEFAULT_PADDING_Y

public static final int DEFAULT_PADDING_Y
Default padding on Y axis

See Also:
Constant Field Values

DEFAULT_INSETS

public static final Insets DEFAULT_INSETS
By default, 1 pixel of margin surrounding component

Constructor Detail

GridBagPanel

public GridBagPanel()
Create a new GridBagPanel.

Method Detail

getPreferredSize

public Dimension getPreferredSize()
Get the preferred size of the component. For compactness, this overrides the superclass and returns the minimum size.

Overrides:
getPreferredSize in class JComponent
Returns:
The preferred size

getMaximumSize

public Dimension getMaximumSize()
Get the maximum size of the component. For looks, this overrides the superclass and returns the minimum height but maximum width.

Overrides:
getMaximumSize in class JComponent
Returns:
The preferred size

add

public void add(Component component,
                int row,
                int col)
Add a component to the Panel, constraining it with the given parameters.

Parameters:
component - The component
row - Row number
col - Col number

add

public void add(Component component,
                int row,
                int col,
                int anchor)
Add a component to the Panel, constraining it with the given parameters.

Parameters:
component - The component
row - Row number
col - Col number
anchor - GridBagConstraints anchor

add

public void add(Component component,
                int row,
                int col,
                int rspan,
                int cspan)
Add a component to the Panel, constraining it with the given parameters.

Parameters:
component - The component
row - Row number
col - Col number
rspan - Row span
cspan - Col span

add

public void add(Component component,
                int row,
                int col,
                int rspan,
                int cspan,
                int anchor,
                int fill)
Add a component to the Panel, constraining it with the given parameters.

Parameters:
component - The component
row - Row number
col - Col number
rspan - Row span
cspan - Col span
anchor - GridBagLayout anchor
fill - GridBagLayout fill

add

public void add(Component component,
                int row,
                int col,
                int rspan,
                int cspan,
                int anchor,
                int fill,
                double wx,
                double wy)
Add a component to the Panel, constraining it with the given parameters.

Parameters:
component - The component
row - Row number
col - Col number
rspan - Row span
cspan - Col span
anchor - GridBagLayout anchor
fill - GridBagLayout fill
wx - Weight along X axis
wy - Weight along Y axis

add

public void add(Component component,
                int row,
                int col,
                int rspan,
                int cspan,
                int anchor,
                int fill,
                double wx,
                double wy,
                int padx,
                int pady)
Add a component to the Panel, constraining it with the given parameters.

Parameters:
component - The component
row - Row number
col - Col number
rspan - Row span
cspan - Col span
anchor - GridBagLayout anchor
fill - GridBagLayout fill
wx - Weight along X axis
wy - Weight along Y axis
padx - Padding on X axis
pady - Padding on Y axis

add

public void add(Component component,
                int row,
                int col,
                int rspan,
                int cspan,
                int anchor,
                int fill,
                double wx,
                double wy,
                int padx,
                int pady,
                Insets insets)
Add a component to the Panel, constraining it with the given parameters.

Parameters:
component - The component
row - Row number
col - Col number
rspan - Row span
cspan - Col span
anchor - GridBagLayout anchor
fill - GridBagLayout fill
wx - Weight along X axis
wy - Weight along Y axis
padx - Padding on X axis
pady - Padding on Y axis
insets - Margin

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona