Search in sources :

Example 21 with Insets

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);
}
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 Insets

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);
    }
}
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 Insets

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);
        }
    });
}
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 24 with Insets

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();
            }
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JLabelPane(pcgen.gui2.util.JLabelPane) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) Hyperactive(pcgen.gui2.tools.Hyperactive) WindowEvent(java.awt.event.WindowEvent) Icon(javax.swing.Icon)

Example 25 with Insets

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;
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets)

Aggregations

Insets (java.awt.Insets)1623 GridBagConstraints (java.awt.GridBagConstraints)1049 GridBagLayout (java.awt.GridBagLayout)828 JPanel (javax.swing.JPanel)728 JLabel (javax.swing.JLabel)652 Dimension (java.awt.Dimension)411 JButton (javax.swing.JButton)366 ActionEvent (java.awt.event.ActionEvent)296 ActionListener (java.awt.event.ActionListener)277 JScrollPane (javax.swing.JScrollPane)226 BorderLayout (java.awt.BorderLayout)221 JTextField (javax.swing.JTextField)205 JCheckBox (javax.swing.JCheckBox)142 Component (java.awt.Component)113 Color (java.awt.Color)103 Font (java.awt.Font)100 Point (java.awt.Point)100 ImageIcon (javax.swing.ImageIcon)100 EmptyBorder (javax.swing.border.EmptyBorder)92 FlowLayout (java.awt.FlowLayout)91