Search in sources :

Example 71 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 72 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)

Example 73 with GridBagConstraints

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]);
        }
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) InfoFacade(pcgen.facade.core.InfoFacade) ButtonGroup(javax.swing.ButtonGroup) TitledBorder(javax.swing.border.TitledBorder)

Example 74 with GridBagConstraints

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();
            }
        }
    });
}
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 75 with GridBagConstraints

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

Aggregations

GridBagConstraints (java.awt.GridBagConstraints)807 GridBagLayout (java.awt.GridBagLayout)585 Insets (java.awt.Insets)520 JPanel (javax.swing.JPanel)472 JLabel (javax.swing.JLabel)412 Dimension (java.awt.Dimension)156 JButton (javax.swing.JButton)131 ActionEvent (java.awt.event.ActionEvent)123 JScrollPane (javax.swing.JScrollPane)119 ActionListener (java.awt.event.ActionListener)116 JTextField (javax.swing.JTextField)99 BorderLayout (java.awt.BorderLayout)98 JCheckBox (javax.swing.JCheckBox)84 TitledBorder (javax.swing.border.TitledBorder)57 ButtonGroup (javax.swing.ButtonGroup)48 JComboBox (javax.swing.JComboBox)45 Color (java.awt.Color)41 FlowLayout (java.awt.FlowLayout)37 Font (java.awt.Font)36 Border (javax.swing.border.Border)35