Package megamek.client.ui
Class GBC2
java.lang.Object
java.awt.GridBagConstraints
megamek.client.ui.GBC2
- All Implemented Interfaces:
Serializable,Cloneable
A GridBagConstraints subclass for setting grid-like layouts where, usually, a left-side label is followed by one or
more chooser components. Using this class means using a persistent instance of GridBagConstraints, so that e.g.
insets or ipad values need to be set only once. Also, it makes use of call chaining (methods return
this).
Note that this class is written with the intention of leaving gridx and gridy entirely at the default (RELATIVE). Not
doing that is likely to disrupt the methods; if specific values need to be used, it is likely better to use a basic
GridBagConstraints instead of GBC2.- See Also:
-
Field Summary
Fields inherited from class java.awt.GridBagConstraints
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()eol()Use this for any component that ends a given row.forLabel()Use this for a left-side label.fullLine()Use this for any component that fills an entire row, like a section title.Use this for any component that fills an entire row but still uses the label insets, like a panel with subcomponents.insets(int top, int left, int bottom, int right) change the insets of thisGridBagConstraintsUse this for a single-column component other than the left-side label.
-
Constructor Details
-
GBC2
public GBC2() -
GBC2
Creates a new GBC2 which uses the given otherInsets for most of its components; the given labelInsets is only used when the forLabel() method is called.- Parameters:
labelInsets- Insets to use when adding a component with forLabel()otherInsets- Insets to use otherwise
-
-
Method Details
-
forLabel
Use this for a left-side label. It sets the anchor to east (right-alignment) and fill to NONE, so the JLabel does not need to use any specific alignment setting. This can also be used for empty labels to skip the label column. It can be directly used by calling panel.add(label, gbc.forLabel());- Returns:
- This GridBagConstraints
-
oneColumn
Use this for a single-column component other than the left-side label. It sets the anchor to west, fill to HORIZONTAL and the gridwidth to 1. It can be directly used by calling panel.add(component, gbc.oneColumn());- Returns:
- This GridBagConstraints
-
eol
Use this for any component that ends a given row. It sets the anchor to west, fill to HORIZONTAL and the gridwidth to REMAINDER. It can be directly used by calling panel.add(component, gbc.eol());- Returns:
- This GridBagConstraints
-
fullLine
Use this for any component that fills an entire row, like a section title. It sets the anchor to CENTER, fill to HORIZONTAL and the gridwidth to REMAINDER. It can be directly used by calling panel.add(component, gbc.fullLine());- Returns:
- This GridBagConstraints
-
fullLineWithLabelInsets
Use this for any component that fills an entire row but still uses the label insets, like a panel with subcomponents. It sets the anchor to CENTER, fill to HORIZONTAL and the gridwidth to REMAINDER. It can be directly used by calling panel.add(component, gbc.fullLineWithLabelInsets());- Returns:
- This GridBagConstraints
-
insets
change the insets of thisGridBagConstraints- Returns:
this- See Also:
-
clone
- Overrides:
clonein classGridBagConstraints
-