|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--com.pegacat.vcf.GridPanel
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 a Panel 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
Inner classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
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 | |
GridPanel()
Constructor calls the JPanel superclass constructor, and initialises the GridBagLayout and GridBagConstraints objects. |
|
GridPanel(java.awt.Image background)
|
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 |
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 |
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. |
void |
paint(java.awt.Graphics g)
|
void |
setBackground(java.awt.Image background)
|
java.lang.String |
toString()
for debugging... |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public GridPanel()
public GridPanel(java.awt.Image background)
Method Detail |
public void setBackground(java.awt.Image background)
public void makeHeavy()
public void makeWide()
public void makeLight()
public java.awt.Component add(java.awt.Component comp)
add
in class java.awt.Container
comp
- the component to addpublic java.awt.Component add(java.awt.Component comp, int x, int y)
comp
- the component to addpublic 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 addpublic 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 java.lang.String toString()
toString
in class java.awt.Component
public void paint(java.awt.Graphics g)
paint
in class java.awt.Container
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |