use of java.awt.Insets in project pcgen by PCGen.
the class CharacterStatsPanel method initComponents.
/**
* Build and initialise the user interface.
*/
private void initComponents() {
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
JLabel label;
ButtonGroup exclusiveGroup;
Border etched = null;
TitledBorder title1 = BorderFactory.createTitledBorder(etched, in_abilities);
title1.setTitleJustification(TitledBorder.LEFT);
this.setBorder(title1);
this.setLayout(gridbag);
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.NORTHWEST;
c.insets = new Insets(2, 2, 2, 2);
final GameMode gameMode = SettingsHandler.getGame();
int row = 0;
exclusiveGroup = new ButtonGroup();
Utility.buildConstraints(c, 0, row++, 3, 1, 0, 0);
label = new JLabel(LanguageBundle.getFormattedString("in_Prefs_abilitiesGenLabel", //$NON-NLS-1$
gameMode.getDisplayName()));
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 0, row, 1, 1, 0, 0);
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesUserRolledButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesUserRolled"));
gridbag.setConstraints(abilitiesUserRolledButton, c);
this.add(abilitiesUserRolledButton);
exclusiveGroup.add(abilitiesUserRolledButton);
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesAllSameButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesAllSame") + ": ");
gridbag.setConstraints(abilitiesAllSameButton, c);
this.add(abilitiesAllSameButton);
exclusiveGroup.add(abilitiesAllSameButton);
Utility.buildConstraints(c, 1, row, 1, 1, 0, 0);
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
abilityScoreCombo = new JComboBoxEx();
for (int i = gameMode.getStatMin(); i <= gameMode.getStatMax(); ++i) {
abilityScoreCombo.addItem(String.valueOf(i));
}
gridbag.setConstraints(abilityScoreCombo, c);
this.add(abilityScoreCombo);
ReferenceManufacturer<RollMethod> mfg = gameMode.getModeContext().getReferenceContext().getManufacturer(RollMethod.class);
List<RollMethod> rollMethods = mfg.getOrderSortedObjects();
if (!rollMethods.isEmpty()) {
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesRolledButton = new JRadioButton("Rolled:");
gridbag.setConstraints(abilitiesRolledButton, c);
this.add(abilitiesRolledButton);
exclusiveGroup.add(abilitiesRolledButton);
Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
abilityRolledModeCombo = new JComboBoxEx();
for (RollMethod rm : rollMethods) {
abilityRolledModeCombo.addItem(rm.getDisplayName());
}
gridbag.setConstraints(abilityRolledModeCombo, c);
this.add(abilityRolledModeCombo);
}
Collection<PointBuyMethod> methods = SettingsHandler.getGame().getModeContext().getReferenceContext().getConstructedCDOMObjects(PointBuyMethod.class);
final int purchaseMethodCount = methods.size();
Utility.buildConstraints(c, 1, row++, 2, 1, 0, 0);
abilitiesPurchasedButton = new JRadioButton(LanguageBundle.getString("in_Prefs_abilitiesPurchased") + ": ");
gridbag.setConstraints(abilitiesPurchasedButton, c);
this.add(abilitiesPurchasedButton);
exclusiveGroup.add(abilitiesPurchasedButton);
Utility.buildConstraints(c, 2, row++, 2, 1, 0, 0);
pMode = new String[purchaseMethodCount];
pModeMethodName = new String[purchaseMethodCount];
int i = 0;
for (PointBuyMethod pbm : methods) {
pMode[i] = pbm.getDescription();
pModeMethodName[i] = pbm.getDisplayName();
i++;
}
abilityPurchaseModeCombo = new JComboBoxEx(pMode);
gridbag.setConstraints(abilityPurchaseModeCombo, c);
this.add(abilityPurchaseModeCombo);
//
if (purchaseMethodCount == 0) {
abilityPurchaseModeCombo.setVisible(false);
abilitiesPurchasedButton.setVisible(false);
}
Utility.buildConstraints(c, 1, row++, 1, 1, 0, 0);
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
Utility.buildConstraints(c, 1, row++, 3, 1, 0, 0);
JButton purchaseModeButton = new JButton(LanguageBundle.getString("in_Prefs_purchaseModeConfig"));
gridbag.setConstraints(purchaseModeButton, c);
this.add(purchaseModeButton);
purchaseModeButton.addActionListener(new PurchaseModeButtonListener());
Utility.buildConstraints(c, 5, 20, 1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
label = new JLabel(" ");
gridbag.setConstraints(label, c);
this.add(label);
}
use of java.awt.Insets in project pcgen by PCGen.
the class PrintPreviewDialog method initLayout.
private void initLayout() {
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
{
//layout top bar
JPanel bar = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.BASELINE;
gbc.insets = new Insets(8, 6, 8, 2);
bar.add(new JLabel("Select Template:"), gbc);
gbc.insets = new Insets(8, 2, 8, 6);
gbc.weightx = 1;
bar.add(sheetBox, gbc);
pane.add(bar, BorderLayout.NORTH);
}
{
Box vbox = Box.createVerticalBox();
previewPanelParent.setPreferredSize(new Dimension(600, 800));
vbox.add(previewPanelParent);
vbox.add(progressBar);
pane.add(vbox, BorderLayout.CENTER);
}
{
Box hbox = Box.createHorizontalBox();
hbox.add(new JLabel("Page:"));
hbox.add(Box.createHorizontalStrut(4));
hbox.add(pageBox);
hbox.add(Box.createHorizontalStrut(10));
hbox.add(new JLabel("Zoom:"));
hbox.add(Box.createHorizontalStrut(4));
hbox.add(zoomBox);
hbox.add(Box.createHorizontalStrut(5));
hbox.add(zoomInButton);
hbox.add(Box.createHorizontalStrut(5));
hbox.add(zoomOutButton);
hbox.add(Box.createHorizontalGlue());
hbox.add(printButton);
hbox.add(Box.createHorizontalStrut(5));
hbox.add(cancelButton);
hbox.setBorder(BorderFactory.createEmptyBorder(8, 5, 8, 5));
pane.add(hbox, BorderLayout.SOUTH);
}
}
use of java.awt.Insets in project pcgen by PCGen.
the class DIWarningDialog method initComponents.
/**
* Initialises the user interface.
*/
private void initComponents() {
setLayout(new GridBagLayout());
JLabel introLabel = new JLabel(introText);
GridBagConstraints gbc = new GridBagConstraints();
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(10, 10, 5, 10);
add(introLabel, gbc);
JTextArea messageArea = new JTextArea();
messageArea.setName("errorMessageBox");
messageArea.setEditable(false);
messageArea.setTabSize(8);
messageArea.setText(fileText);
JScrollPane messageAreaContainer = new JScrollPane(messageArea);
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 1.0);
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 10, 5, 10);
add(messageAreaContainer, gbc);
JLabel dummy = new JLabel(" ");
Utility.buildRelativeConstraints(gbc, 1, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
add(dummy, gbc);
JButton yesButton = new JButton(LanguageBundle.getString("in_yes"));
yesButton.setActionCommand(ACTION_YES);
yesButton.addActionListener(this);
Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.EAST);
gbc.insets = new Insets(5, 5, 10, 5);
add(yesButton, gbc);
JButton noButton = new JButton(LanguageBundle.getString("in_no"));
noButton.setActionCommand(ACTION_NO);
noButton.addActionListener(this);
Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.EAST);
add(noButton, gbc);
JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel"));
cancelButton.setActionCommand(ACTION_CANCEL);
cancelButton.addActionListener(this);
getRootPane().setDefaultButton(cancelButton);
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
gbc.insets = new Insets(5, 5, 10, 10);
add(cancelButton, gbc);
pack();
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
result = JOptionPane.CANCEL_OPTION;
setVisible(false);
}
});
}
use of java.awt.Insets 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.Insets 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;
}
Aggregations