Utilitypublic class Utility extends Object
Fields Summary |
---|
public static final Font | titleFont | public static final Font | labelFont | public static final Font | choiceFont | public static final Font | editFont | public static final Font | creditFont | private static Locale[] | localeList |
Methods Summary |
---|
public static void | fixGrid(java.awt.Container cont, int columns)Provides easy way to use basic functions of GridBagLayout, without
the complications. After building a panel, and inserting all the
subcomponents, call this to lay it out in the desired number of columns.
GridBagLayout gridbag = new GridBagLayout();
cont.setLayout(gridbag);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.VERTICAL;
c.weightx = 1.0;
c.insets = new Insets(2,2,2,2);
Component[] components = cont.getComponents();
for (int i = 0; i < components.length; ++i) {
int colNumber = i%columns;
c.gridwidth = 1; // default
if ((i%columns) == columns - 1)
c.gridwidth = GridBagConstraints.REMAINDER; // last in grid
if (components[i] instanceof Label) {
switch (((Label)components[i]).getAlignment()) {
case Label.CENTER: c.anchor = GridBagConstraints.CENTER; break;
case Label.LEFT: c.anchor = GridBagConstraints.WEST; break;
case Label.RIGHT: c.anchor = GridBagConstraints.EAST; break;
}
}
gridbag.setConstraints(components[i], c);
}
| public static java.util.Locale[] | getG7Locales()Get the G7 locale list for demos.
return localeList;
| public static void | setInsets(java.awt.Container cont, java.awt.Component comp, java.awt.Insets insets)Provides easy way to change the spacing around an object in a GridBagLayout.
Call AFTER fixGridBag, passing in the container, the component, and the
new insets.
GridBagLayout gbl = (GridBagLayout)cont.getLayout();
GridBagConstraints g = gbl.getConstraints(comp);
g.insets = insets;
gbl.setConstraints(comp,g);
| public static void | setText(java.awt.TextComponent area, java.lang.String newText)
String foo = area.getText();
if (foo.equals(newText)) return;
area.setText(newText);
|
|