use of java.awt.GridBagConstraints 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.GridBagConstraints 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.GridBagConstraints in project pcgen by PCGen.
the class ChooserDialog method initComponents.
private void initComponents() {
setTitle(chooser.getName());
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
//detach listeners from the chooser
treeViewModel.setDelegate(null);
listModel.setListFacade(null);
chooser.getRemainingSelections().removeReferenceListener(ChooserDialog.this);
}
});
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
JSplitPane split = new JSplitPane();
JPanel leftPane = new JPanel(new BorderLayout());
if (availTable != null) {
availTable.setAutoCreateRowSorter(true);
availTable.setTreeViewModel(treeViewModel);
availTable.getRowSorter().toggleSortOrder(0);
availTable.addActionListener(this);
leftPane.add(new JScrollPane(availTable), BorderLayout.CENTER);
} else {
availInput.addActionListener(this);
Dimension maxDim = new Dimension(Integer.MAX_VALUE, availInput.getPreferredSize().height);
availInput.setMaximumSize(maxDim);
JPanel availPanel = new JPanel();
availPanel.setLayout(new BoxLayout(availPanel, BoxLayout.PAGE_AXIS));
availPanel.add(Box.createRigidArea(new Dimension(10, 30)));
availPanel.add(Box.createVerticalGlue());
availPanel.add(new JLabel(LanguageBundle.getString("in_uichooser_value")));
availPanel.add(availInput);
availPanel.add(Box.createVerticalGlue());
leftPane.add(availPanel, BorderLayout.WEST);
}
JPanel buttonPane1 = new JPanel(new FlowLayout());
JButton addButton = new JButton(chooser.getAddButtonName());
addButton.setActionCommand("ADD");
addButton.addActionListener(this);
buttonPane1.add(addButton);
buttonPane1.add(new JLabel(Icons.Forward16.getImageIcon()));
leftPane.add(buttonPane1, BorderLayout.SOUTH);
split.setLeftComponent(leftPane);
JPanel rightPane = new JPanel(new BorderLayout());
JPanel labelPane = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
labelPane.add(new JLabel(chooser.getSelectionCountName()), new GridBagConstraints());
remainingLabel.setText(chooser.getRemainingSelections().get().toString());
labelPane.add(remainingLabel, gbc);
labelPane.add(new JLabel(chooser.getSelectedTableTitle()), gbc);
rightPane.add(labelPane, BorderLayout.NORTH);
list.setModel(listModel);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addActionListener(this);
rightPane.add(new JScrollPane(list), BorderLayout.CENTER);
JPanel buttonPane2 = new JPanel(new FlowLayout());
buttonPane2.add(new JLabel(Icons.Back16.getImageIcon()));
JButton removeButton = new JButton(chooser.getRemoveButtonName());
removeButton.setActionCommand("REMOVE");
removeButton.addActionListener(this);
buttonPane2.add(removeButton);
rightPane.add(buttonPane2, BorderLayout.SOUTH);
split.setRightComponent(rightPane);
if (chooser.isInfoAvailable()) {
JSplitPane infoSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
infoSplit.setTopComponent(split);
infoSplit.setBottomComponent(infoPane);
infoSplit.setResizeWeight(0.8);
pane.add(infoSplit, BorderLayout.CENTER);
if (availTable != null) {
availTable.getSelectionModel().addListSelectionListener(this);
}
} else {
pane.add(split, BorderLayout.CENTER);
}
JPanel bottomPane = new JPanel(new FlowLayout());
//$NON-NLS-1$
JButton button = new JButton(LanguageBundle.getString("in_ok"));
//$NON-NLS-1$
button.setMnemonic(LanguageBundle.getMnemonic("in_mn_ok"));
button.setActionCommand("OK");
button.addActionListener(this);
bottomPane.add(button);
//$NON-NLS-1$
button = new JButton(LanguageBundle.getString("in_cancel"));
//$NON-NLS-1$
button.setMnemonic(LanguageBundle.getMnemonic("in_mn_cancel"));
button.setActionCommand("CANCEL");
button.addActionListener(this);
bottomPane.add(button);
pane.add(bottomPane, BorderLayout.SOUTH);
}
use of java.awt.GridBagConstraints 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.GridBagConstraints in project pcgen by PCGen.
the class LanguageChooserDialog method initComponents.
private void initComponents() {
setTitle(chooser.getName());
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
//detach listeners from the chooser
treeViewModel.setDelegate(null);
listModel.setListFacade(null);
chooser.getRemainingSelections().removeReferenceListener(LanguageChooserDialog.this);
}
});
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
JSplitPane split = new JSplitPane();
JPanel leftPane = new JPanel(new BorderLayout());
//leftPane.add(new JLabel("Available Languages"), BorderLayout.NORTH);
availTable.setAutoCreateRowSorter(true);
availTable.setTreeViewModel(treeViewModel);
availTable.getRowSorter().toggleSortOrder(0);
availTable.addActionListener(this);
leftPane.add(new JScrollPane(availTable), BorderLayout.CENTER);
JPanel buttonPane1 = new JPanel(new FlowLayout());
//$NON-NLS-1$
JButton addButton = new JButton(LanguageBundle.getString("in_sumLangAddLanguage"));
addButton.setActionCommand("ADD");
addButton.addActionListener(this);
buttonPane1.add(addButton);
buttonPane1.add(new JLabel(Icons.Forward16.getImageIcon()));
leftPane.add(buttonPane1, BorderLayout.SOUTH);
split.setLeftComponent(leftPane);
JPanel rightPane = new JPanel(new BorderLayout());
JPanel labelPane = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = GridBagConstraints.REMAINDER;
//$NON-NLS-1$
labelPane.add(//$NON-NLS-1$
new JLabel(LanguageBundle.getString("in_sumLangRemain")), new GridBagConstraints());
remainingLabel.setText(chooser.getRemainingSelections().get().toString());
labelPane.add(remainingLabel, gbc);
//$NON-NLS-1$
labelPane.add(new JLabel(LanguageBundle.getString("in_sumSelectedLang")), gbc);
rightPane.add(labelPane, BorderLayout.NORTH);
list.setModel(listModel);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addActionListener(this);
rightPane.add(new JScrollPane(list), BorderLayout.CENTER);
JPanel buttonPane2 = new JPanel(new FlowLayout());
buttonPane2.add(new JLabel(Icons.Back16.getImageIcon()));
//$NON-NLS-1$
JButton removeButton = new JButton(LanguageBundle.getString("in_sumLangRemoveLanguage"));
removeButton.setActionCommand("REMOVE");
removeButton.addActionListener(this);
buttonPane2.add(removeButton);
rightPane.add(buttonPane2, BorderLayout.SOUTH);
split.setRightComponent(rightPane);
pane.add(split, BorderLayout.CENTER);
JPanel bottomPane = new JPanel(new FlowLayout());
//$NON-NLS-1$
JButton button = new JButton(LanguageBundle.getString("in_ok"));
//$NON-NLS-1$
button.setMnemonic(LanguageBundle.getMnemonic("in_mn_ok"));
button.setActionCommand("OK");
button.addActionListener(this);
bottomPane.add(button);
//$NON-NLS-1$
button = new JButton(LanguageBundle.getString("in_cancel"));
//$NON-NLS-1$
button.setMnemonic(LanguageBundle.getMnemonic("in_mn_cancel"));
button.setActionCommand("CANCEL");
button.addActionListener(this);
bottomPane.add(button);
pane.add(bottomPane, BorderLayout.SOUTH);
}
Aggregations