|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--com.ca.commons.cbutil.CBPanel
Java layout managers are frustrating, badly written pieces of garbage that are difficult to use, erratic, throw strange errors, and are generally junk. The only one worth spitting on is GridBagLayout, but it's clumsy and inconvenient to use.
This class wraps up JPanel with an intrinsic GridBagLayout and constraints object, and provides a bunch of new add() ftns to make stuff faster and easier. For me, anyway :-).
This works nicely for adding single height objects of different widths, using ftns such as add(), addline(), newline(), or addwide(). High objects can be placed explicitly using add(x,y,width,height).
The concept of a 'cursor' position is used, with cells being added to the next 'cursor' position, and the cursor being adjusted with 'newline()', or a fixed positional placement.
e.g.
add(a); add(b); add(c); newLine();
addLine(d);
add(e); addLine(f);
addWide(g,2); addLine(h);
addBig(i,2);
add(j,1,2,3,8)
should produce something like:
[ a ] [ b ] [ c ]
[ d ]
[ e ] [ f ]
[ g ] [ h ]
[ ]
[ i ]
... ... ...
... [ j ]
(YMMV :-) )
- Chris
| Nested Class Summary |
| Nested classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
protected java.awt.GridBagConstraints |
c
|
protected int |
xpos
|
protected int |
ypos
|
| 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 | |
CBPanel()
Constructor calls the JPanel superclass constructor, and initialises the GridBagLayout and GridBagConstraints objects. |
|
| Method Summary | |
java.awt.Component |
add(java.awt.Component comp)
Add the next component in a straight line, automatically incrementing the X position 'cursor'. |
java.awt.Component |
add(java.awt.Component comp,
int x,
int y)
Add a unit cell object to a specific x and y position. |
java.awt.Component |
add(java.awt.Component comp,
int x,
int y,
int width,
int height)
Adds a component to the specified x,y cell position, with a size spanning (width, height) cells. |
void |
addGreedyWide(java.awt.Component comp)
|
void |
addGreedyWide(java.awt.Component comp,
int width)
|
void |
addLine(java.awt.Component comp)
Adds a component taking up the remainder of the line (using GridBagConstraints.REMAINDER), and increments the cursor to the next line. |
void |
addLines(java.awt.Component comp,
int height)
Adds a large multi - line component at the next cursor position, increments the cursor to the start of the next line immediately below the object. |
void |
addln(java.awt.Component comp)
Adds a component taking up the remainder of the line (using GridBagConstraints.REMAINDER), and increments the cursor to the next line. |
void |
addWide(java.awt.Component comp,
int width)
Adds a wider-than-usual component, updating the cursor as appropriate. |
void |
makeHeavy()
Makes all components added after this call expand to fill all available space. |
void |
makeHigh()
Makes all components added after this call expand to fill all available height (but not width). |
void |
makeLight()
|
void |
makeWide()
Makes all components added after this call expand to fill all available width (but not height). |
void |
newLine()
Adjusts the cursor to the next line down. |
java.lang.String |
toString()
for debugging... gets current state... |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.awt.GridBagConstraints c
protected int xpos
protected int ypos
| Constructor Detail |
public CBPanel()
| Method Detail |
public void makeHeavy()
public void makeWide()
public void makeLight()
public void makeHigh()
public java.awt.Component add(java.awt.Component comp)
add in class java.awt.Containercomp - the component to add
public java.awt.Component add(java.awt.Component comp,
int x,
int y)
comp - the component to add
public java.awt.Component add(java.awt.Component comp,
int x,
int y,
int width,
int height)
comp - the component to addpublic void newLine()
public void addLine(java.awt.Component comp)
comp - the component to addpublic void addln(java.awt.Component comp)
comp - the component to add
public void addLines(java.awt.Component comp,
int height)
comp - the component to addheight - the number of cells height the component is.
public void addWide(java.awt.Component comp,
int width)
public void addGreedyWide(java.awt.Component comp)
public void addGreedyWide(java.awt.Component comp,
int width)
public java.lang.String toString()
toString in class java.awt.Component
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||