public class GBC extends GridBagConstraints
GridBagConstraints objects.
One of the biggest hurdles working with GridBag layouts is the number of times you need to type the string GridBagConstraints into the text editor. The GBC class extends the java.awt.GridBagConstraints class and adds helper methods to set fields and to allow GBC objects to be used as a "cursor" into the layout. If nothing else, a programmer can access the class variables via the GBC class rather than having to type GridBagConstraints all the time.
The GridBagLayout manager makes its own copy of the GridBagConstraints object so it is possible to use the same GBC object for all controls that you add to a container. For example:
JPanel aPanel = new JPanel(new GridBagLayout()); GBC gbc = new GBC(); // Add controls in the first column // Right align the controls gbc.right(); // Don't resize gbc.nofill(); aPanel.add(control1, gbc); aPanel.add(control2, gbc.down()); aPanel.add(control3, gbc.down()); // Center the controls in the second column gbc.center(); // Grow horizontally, and take up all new room along x-axis gbc.fillHorizontal(); gbc.weight(1, 0); aPanel.add(control4, gbc.xy(1,0); aPanel.add(control5, gbc.down()); aPanel.add(control6, gbc.down()); // Add controls to the third column // Left aligned and won't resize gbc.nofill(); gbc.weight(0,0); aPanel.add(control7, gbc.xy(2,0)); aPanel.add(control8, gbc.down()); aPanel.add(control9, gbc.down()); ...
ABOVE_BASELINE, ABOVE_BASELINE_LEADING, ABOVE_BASELINE_TRAILING, anchor, BASELINE, BASELINE_LEADING, BASELINE_TRAILING, BELOW_BASELINE, BELOW_BASELINE_LEADING, BELOW_BASELINE_TRAILING, BOTH, CENTER, EAST, fill, FIRST_LINE_END, FIRST_LINE_START, gridheight, gridwidth, gridx, gridy, HORIZONTAL, insets, ipadx, ipady, LAST_LINE_END, LAST_LINE_START, LINE_END, LINE_START, NONE, NORTH, NORTHEAST, NORTHWEST, PAGE_END, PAGE_START, RELATIVE, REMAINDER, SOUTH, SOUTHEAST, SOUTHWEST, VERTICAL, weightx, weighty, WEST| Constructor and Description |
|---|
GBC() |
GBC(int fill,
int anchor) |
GBC(int fill,
int anchor,
int width,
int height) |
| Modifier and Type | Method and Description |
|---|---|
GBC |
anchorCenter() |
GBC |
anchorEast() |
GBC |
anchorLeft()
Set anchor = WEST.
|
GBC |
anchorNorth() |
GBC |
anchorNortheast() |
GBC |
anchorNorthwest() |
GBC |
anchorRight() |
GBC |
anchorSouth() |
GBC |
anchorSoutheast() |
GBC |
anchorSouthwest() |
GBC |
anchorWest() |
GBC |
down() |
GBC |
fillBoth() |
GBC |
fillHorizontal() |
GBC |
fillNone() |
GBC |
fillVertical() |
static GBC |
getDefaultGbc()
A static factory method that initializes a constraint object with the most
commonly used values.
|
GBC |
insets(int top,
int left,
int bottom,
int right) |
GBC |
left() |
GBC |
pad(int x,
int y) |
GBC |
right() |
GBC |
size(int width,
int height) |
GBC |
up() |
GBC |
weight(int wx,
int wy) |
GBC |
x(int x) |
GBC |
xy(int x,
int y) |
GBC |
y(int y) |
clonepublic GBC()
public GBC(int fill,
int anchor)
public GBC(int fill,
int anchor,
int width,
int height)
public static GBC getDefaultGbc()
public GBC anchorLeft()
public GBC anchorCenter()
public GBC anchorRight()
public GBC anchorWest()
public GBC anchorEast()
public GBC anchorNorth()
public GBC anchorSouth()
public GBC anchorNortheast()
public GBC anchorNorthwest()
public GBC anchorSoutheast()
public GBC anchorSouthwest()
public GBC fillNone()
public GBC fillBoth()
public GBC fillVertical()
public GBC fillHorizontal()
public GBC x(int x)
public GBC y(int y)
public GBC xy(int x, int y)
public GBC down()
public GBC up()
public GBC right()
public GBC left()
public GBC insets(int top, int left, int bottom, int right)
public GBC weight(int wx, int wy)
public GBC size(int width, int height)
public GBC pad(int x, int y)
Copyright © 2016 The American National Corpus. All rights reserved.