use of java.awt.GridBagLayout in project pcgen by PCGen.
the class RadioChooserDialog method buildButtonPanel.
/**
* Create the panel of radio buttons.
*/
private void buildButtonPanel() {
ListFacade<InfoFacade> availableList = chooser.getAvailableList();
int row = 0;
avaRadioButton = new JRadioButton[availableList.getSize()];
avaGroup = new ButtonGroup();
// Create the buttons
for (InfoFacade infoFacade : availableList) {
avaRadioButton[row] = new JRadioButton(infoFacade.toString(), false);
avaGroup.add(avaRadioButton[row]);
avaRadioButton[row].addActionListener(this);
++row;
}
int numRows = row;
if (numRows > 0) {
avaRadioButton[0].setSelected(true);
selectedButton = avaRadioButton[0];
}
// Layout the buttons
GridBagLayout gridbag = new GridBagLayout();
buttonPanel = new JPanel();
TitledBorder title = BorderFactory.createTitledBorder(null, "");
buttonPanel.setBorder(title);
buttonPanel.setLayout(gridbag);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
if (numRows > 11) {
buildTwoColLayout(numRows, c, gridbag);
} else {
for (int i = 0; i < numRows; ++i) {
int cr = i;
c.anchor = GridBagConstraints.WEST;
Utility.buildConstraints(c, 0, cr, 2, 1, 1, 0);
gridbag.setConstraints(avaRadioButton[i], c);
buttonPanel.add(avaRadioButton[i]);
}
}
}
use of java.awt.GridBagLayout in project pcgen by PCGen.
the class TipOfTheDay method initUI.
//
// initialize the dialog
//
private void initUI() {
final JPanel panel = new JPanel(new BorderLayout(2, 2));
panel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
JLabel iconLabel;
final Icon icon = Icons.TipOfTheDay24.getImageIcon();
iconLabel = icon != null ? new JLabel(icon) : new JLabel("TipOfTheDay24.gif");
iconLabel.setOpaque(true);
panel.add(iconLabel, BorderLayout.WEST);
final JLabel lblDidYouKnow = new JLabel(" " + LanguageBundle.getString("in_tod_didyouknow"));
FontManipulation.xxlarge(lblDidYouKnow);
lblDidYouKnow.setOpaque(true);
tipText = new JLabelPane();
tipText.setBorder(null);
tipText.setFocusable(false);
tipText.addHyperlinkListener(new Hyperactive());
final JScrollPane pane = new JScrollPane(tipText);
pane.setBorder(null);
final JPanel content = new JPanel(new BorderLayout(0, 2));
content.add(lblDidYouKnow, BorderLayout.NORTH);
content.add(pane, BorderLayout.CENTER);
content.setPreferredSize(new Dimension(585, 230));
panel.add(content, BorderLayout.CENTER);
chkShowTips = new JCheckBox(LanguageBundle.getString("in_tod_showTips"), propertyContext.initBoolean("showTipOfTheDay", true));
final JButton btnClose = new JButton(LanguageBundle.getString("in_close"));
btnClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
btnClose.addActionListener(this);
// TODO give focus to close button
final JButton btnPrevTip = new JButton(LanguageBundle.getString("in_tod_prevTip"));
btnPrevTip.setMnemonic(LanguageBundle.getMnemonic("in_mn_tod_prevTip"));
btnPrevTip.addActionListener(this);
btnPrevTip.setActionCommand(PREV);
final JButton btnNextTip = new JButton(LanguageBundle.getString("in_tod_nextTip"));
btnNextTip.setMnemonic(LanguageBundle.getMnemonic("in_mn_tod_nextTip"));
btnNextTip.addActionListener(this);
btnNextTip.setActionCommand(NEXT);
final JPanel actions = new JPanel(new GridBagLayout());
final GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0);
actions.add(chkShowTips, c);
final JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttons.add(btnPrevTip);
buttons.add(btnNextTip);
buttons.add(btnClose);
c.gridx = 1;
c.anchor = GridBagConstraints.EAST;
actions.add(buttons, c);
panel.add(actions, BorderLayout.SOUTH);
setContentPane(panel);
getRootPane().setDefaultButton(btnClose);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
quit();
}
});
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
quit();
}
}
});
}
use of java.awt.GridBagLayout in project pcgen by PCGen.
the class CoreViewFrame method initialize.
public void initialize(CharacterFacade character) {
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
getContentPane().setLayout(gridbag);
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.NORTHWEST;
c.insets = new Insets(2, 2, 2, 2);
int col = 0;
Utility.buildConstraints(c, col, 0, 1, 1, 100, 20);
JLabel label = new JLabel(LanguageBundle.getFormattedString(//$NON-NLS-1$
"in_CoreView_Perspective"));
gridbag.setConstraints(label, c);
getContentPane().add(label);
Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
gridbag.setConstraints(perspectiveChooser, c);
getContentPane().add(perspectiveChooser);
Utility.buildConstraints(c, 0, 2, col, 1, 0, 1000);
viewTable.setAutoCreateRowSorter(true);
JScrollPane pane = new JScrollPane(viewTable);
pane.setPreferredSize(new Dimension(500, 300));
gridbag.setConstraints(pane, c);
getContentPane().add(pane);
setTitle("Core Debug View");
getContentPane().setSize(500, 400);
pack();
Utility.centerComponent(this, true);
}
use of java.awt.GridBagLayout in project pcgen by PCGen.
the class OptionsPathDialog method initComponents.
private void initComponents() {
setResizable(false);
setTitle("Directory for options.ini location");
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
getContentPane().setLayout(new GridBagLayout());
GridBagConstraints gridBagConstraints = new GridBagConstraints();
JLabel label = new JLabel("Select a directory to store PCGen options in:");
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.insets = new Insets(4, 4, 0, 4);
getContentPane().add(label, gridBagConstraints);
gridBagConstraints.insets = new Insets(2, 0, 2, 0);
getContentPane().add(new JSeparator(), gridBagConstraints);
label = new JLabel("If you have an existing options.ini file," + "then select the directory containing that file");
gridBagConstraints.insets = new Insets(4, 4, 4, 4);
getContentPane().add(label, gridBagConstraints);
ActionListener handler = new ActionHandler();
ButtonGroup group = new ButtonGroup();
gridBagConstraints.insets = new Insets(0, 4, 0, 4);
addRadioButton("<html><b>PCGen Dir</b>: This is the directory that PCGen is installed into", SettingsFilesPath.pcgen.name(), group, handler, gridBagConstraints);
// Remark: do mac user really need to be able to put the file either in a specific mac dir or home?
if (SystemUtils.IS_OS_MAC_OSX) {
addRadioButton("<html><b>Mac User Dir</b>", SettingsFilesPath.mac_user.name(), group, handler, gridBagConstraints);
} else if (SystemUtils.IS_OS_UNIX) {
// putting it the same way as mac. merging all and using a system config dir instead would be better IMHO.
addRadioButton("<html><b>Freedesktop configuration sub-directory</b> Use for most Linux/BSD", SettingsFilesPath.FD_USER.name(), group, handler, gridBagConstraints);
}
addRadioButton("<html><b>Home Dir</b>: This is your home directory", SettingsFilesPath.user.name(), group, handler, gridBagConstraints);
addRadioButton("Select a directory to use", "select", group, handler, gridBagConstraints);
dirField.setText(ConfigurationSettings.getSettingsDirFromFilePath(selectedDir));
dirField.setEditable(false);
gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE;
gridBagConstraints.weightx = 1;
gridBagConstraints.insets = new Insets(0, 4, 0, 0);
getContentPane().add(dirField, gridBagConstraints);
dirButton.setText("...");
dirButton.setEnabled(false);
dirButton.addActionListener(handler);
dirButton.setActionCommand("custom");
dirButton.setMargin(new Insets(2, 2, 2, 2));
GridBagConstraints bagConstraints = new GridBagConstraints();
bagConstraints.gridwidth = GridBagConstraints.REMAINDER;
bagConstraints.insets = new Insets(0, 0, 0, 4);
getContentPane().add(dirButton, bagConstraints);
JButton okButton = new JButton("OK");
okButton.setPreferredSize(new Dimension(75, 23));
okButton.setActionCommand("ok");
okButton.addActionListener(handler);
bagConstraints.insets = new Insets(4, 0, 4, 0);
getContentPane().add(okButton, bagConstraints);
getRootPane().setDefaultButton(okButton);
pack();
setLocationRelativeTo(null);
}
use of java.awt.GridBagLayout in project voltdb by VoltDB.
the class ZaurusEditor method initGUI.
private void initGUI() {
// without connection there are no tables
// vAllTables is a local variable with all table names in the database
// vHoldTableNames holds the table names which have a ZaurusTableForm
Vector vAllTables = getAllTables();
if (vAllTables == null) {
return;
}
// initialize a new list for the table names which have a form in pForm
vHoldTableNames = new Vector(20);
vHoldForms = new Vector(20);
// this holds the card panel pForm for the forms in the top
// a card panel pButton below
// the both card panels form a panel which is centered in this
// and a status line in the south
this.setLayout(new BorderLayout(3, 3));
// >>> the top of this: the entry forms in pForm
// pFormButs holds in the center the forms card panel pForm and
// in the south the button card panel pButton
Panel pFormButs = new Panel();
pFormButs.setLayout(new BorderLayout(3, 3));
pForm = new Panel();
lForm = new CardLayout(2, 2);
pForm.setLayout(lForm);
// the search panel containing the list of all tables and
// the entry fields for search words in the Center
Panel pEntry = new Panel();
pEntry.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.insets = new Insets(3, 3, 3, 3);
c.gridwidth = 1;
c.gridheight = 1;
c.weightx = c.weighty = 1;
c.anchor = GridBagConstraints.WEST;
c.gridy = 0;
c.gridx = 0;
pEntry.add(new Label("Search table"), c);
c.gridx = 1;
// get all table names and show a drop down list of them in cTables
cTables = new Choice();
for (Enumeration e = vAllTables.elements(); e.hasMoreElements(); ) {
cTables.addItem((String) e.nextElement());
}
c.gridwidth = 2;
pEntry.add(cTables, c);
c.gridy = 1;
c.gridx = 0;
c.gridwidth = 1;
pEntry.add(new Label("Search words"), c);
c.gridx = 1;
c.gridwidth = 2;
fSearchWords = new TextField(8);
pEntry.add(fSearchWords, c);
// use search words
c.gridwidth = 1;
c.gridy = 2;
c.gridx = 0;
pEntry.add(new Label("Use search words"), c);
gAllWords = new CheckboxGroup();
Checkbox[] checkboxes = new Checkbox[2];
checkboxes[0] = new Checkbox("all", gAllWords, true);
c.gridx = 1;
pEntry.add(checkboxes[0], c);
checkboxes[1] = new Checkbox("any ", gAllWords, false);
c.gridx = 2;
pEntry.add(checkboxes[1], c);
// ignore case
c.gridy = 3;
c.gridx = 0;
pEntry.add(new Label("Ignore case"), c);
gIgnoreCase = new CheckboxGroup();
Checkbox[] checkboxes1 = new Checkbox[2];
checkboxes1[0] = new Checkbox("yes", gIgnoreCase, true);
c.gridx = 1;
pEntry.add(checkboxes1[0], c);
checkboxes1[1] = new Checkbox("no", gIgnoreCase, false);
c.gridx = 2;
pEntry.add(checkboxes1[1], c);
// Match column exactly
c.gridy = 4;
c.gridx = 0;
pEntry.add(new Label("Match whole col"), c);
gNoMatchWhole = new CheckboxGroup();
Checkbox[] checkboxes2 = new Checkbox[2];
checkboxes2[0] = new Checkbox("no", gNoMatchWhole, true);
c.gridx = 1;
pEntry.add(checkboxes2[0], c);
checkboxes2[1] = new Checkbox("yes ", gNoMatchWhole, false);
c.gridx = 2;
pEntry.add(checkboxes2[1], c);
pForm.add("search", pEntry);
pFormButs.add("Center", pForm);
// the buttons
this.initButtons();
pButton = new Panel();
lButton = new CardLayout(2, 2);
pButton.setLayout(lButton);
pButton.add("search", pSearchButs);
pButton.add("edit", pEditButs);
pButton.add("insert", pInsertButs);
pFormButs.add("South", pButton);
this.add("Center", pFormButs);
// >>> the South: status line at the bottom
Font fFont = new Font("Dialog", Font.PLAIN, 10);
ZaurusEditor.tStatus = new TextField("");
ZaurusEditor.tStatus.setEditable(false);
this.add("South", ZaurusEditor.tStatus);
}
Aggregations