Search in sources :

Example 21 with GridBagConstraints

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);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) RollMethod(pcgen.cdom.content.RollMethod) GridBagLayout(java.awt.GridBagLayout) PointBuyMethod(pcgen.core.PointBuyMethod) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) GameMode(pcgen.core.GameMode) ButtonGroup(javax.swing.ButtonGroup) JComboBoxEx(pcgen.gui2.util.JComboBoxEx) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder)

Example 22 with GridBagConstraints

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);
    }
}
Also used : JPanel(javax.swing.JPanel) Container(java.awt.Container) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) BorderLayout(java.awt.BorderLayout) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) Dimension(java.awt.Dimension)

Example 23 with GridBagConstraints

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) JSplitPane(javax.swing.JSplitPane)

Example 24 with GridBagConstraints

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);
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter)

Example 25 with GridBagConstraints

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) JLabel(javax.swing.JLabel) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) JSplitPane(javax.swing.JSplitPane)

Aggregations

GridBagConstraints (java.awt.GridBagConstraints)1628 GridBagLayout (java.awt.GridBagLayout)1200 Insets (java.awt.Insets)1044 JPanel (javax.swing.JPanel)960 JLabel (javax.swing.JLabel)833 JButton (javax.swing.JButton)350 ActionEvent (java.awt.event.ActionEvent)303 ActionListener (java.awt.event.ActionListener)284 Dimension (java.awt.Dimension)266 JScrollPane (javax.swing.JScrollPane)252 JTextField (javax.swing.JTextField)250 BorderLayout (java.awt.BorderLayout)214 JCheckBox (javax.swing.JCheckBox)200 JComboBox (javax.swing.JComboBox)101 Color (java.awt.Color)98 FlowLayout (java.awt.FlowLayout)93 TitledBorder (javax.swing.border.TitledBorder)91 Font (java.awt.Font)85 BoxLayout (javax.swing.BoxLayout)82 EmptyBorder (javax.swing.border.EmptyBorder)72