use of java.awt.GridBagConstraints 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.GridBagConstraints 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.GridBagConstraints in project pcgen by PCGen.
the class MainAbout method buildConstraints.
/**
* Construct a GridBagConstraints record using defaults and
* some basic supplied details.
*
* @param xPos The column the field should appear in.
* @param yPos The row the field should appear in.
* @param anchor Where the field should be positioned.
* @return A GridBagConstraints object.
*/
private GridBagConstraints buildConstraints(int xPos, int yPos, int anchor) {
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridx = xPos;
constraints.gridy = yPos;
constraints.fill = GridBagConstraints.NONE;
constraints.anchor = anchor;
constraints.insets = new Insets(5, 0, 5, 10);
return constraints;
}
use of java.awt.GridBagConstraints 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.GridBagConstraints 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);
}
Aggregations