Search in sources :

Example 31 with FlowLayout

use of java.awt.FlowLayout 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 32 with FlowLayout

use of java.awt.FlowLayout 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 33 with FlowLayout

use of java.awt.FlowLayout in project pcgen by PCGen.

the class SinglePrefDialog method initComponents.

private void initComponents() {
    // Build the control panel (OK/Cancel buttons)
    controlPanel = new JPanel();
    controlPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    JButton okButton = new JButton(LanguageBundle.getString("in_ok"));
    okButton.setMnemonic(LanguageBundle.getMnemonic("in_mn_ok"));
    controlPanel.add(okButton);
    okButton.addActionListener(evt -> okButtonActionPerformed());
    JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel"));
    cancelButton.setMnemonic(LanguageBundle.getMnemonic("in_mn_cancel"));
    controlPanel.add(cancelButton);
    cancelButton.addActionListener(evt -> cancelButtonActionPerformed());
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JButton(javax.swing.JButton)

Example 34 with FlowLayout

use of java.awt.FlowLayout 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 35 with FlowLayout

use of java.awt.FlowLayout in project pcgen by PCGen.

the class AbstractDialog method initialize.

private void initialize() {
    okButton = new JButton(LanguageBundle.getString(getOkKey()));
    okButton.setMnemonic(LanguageBundle.getMnemonic(getOkMnKey()));
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okButtonActionPerformed();
        }
    });
    JButton cancelButton = new JButton(LanguageBundle.getString(getCancelKey()));
    cancelButton.setMnemonic(LanguageBundle.getMnemonic(getCancelMnKey()));
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelButtonActionPerformed();
        }
    });
    JButton bApply = null;
    if (includeApplyButton()) {
        //$NON-NLS-1$
        bApply = new JButton(LanguageBundle.getString("in_apply"));
        //$NON-NLS-1$
        bApply.setMnemonic(LanguageBundle.getMnemonic("in_mn_apply"));
        bApply.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent evt) {
                applyButtonActionPerformed();
            }
        });
    }
    // initialize button panel
    JPanel buttonPanel = new JPanel();
    //$NON-NLS-1$
    buttonPanel.setBorder(UIManager.getBorder("OptionPane.border"));
    buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    // offer identical width for Preferred size if needed
    //$NON-NLS-1$
    boolean sameSize = UIManager.getBoolean("OptionPane.sameSizeButtons");
    if (sameSize) {
        int max = Math.max(okButton.getPreferredSize().width, cancelButton.getPreferredSize().width);
        if (includeApplyButton()) {
            max = Math.max(max, bApply.getPreferredSize().width);
            bApply.setPreferredSize(new Dimension(max, bApply.getPreferredSize().height));
        }
        okButton.setPreferredSize(new Dimension(max, okButton.getPreferredSize().height));
        cancelButton.setPreferredSize(new Dimension(max, cancelButton.getPreferredSize().height));
    }
    // add button, respecting OptionPane.isYesLast
    //$NON-NLS-1$
    boolean isYesLast = UIManager.getBoolean("OptionPane.isYesLast");
    //$NON-NLS-1$
    int padding = UIManager.getInt("OptionPane.buttonPadding");
    if (isYesLast) {
        if (includeApplyButton()) {
            buttonPanel.add(bApply);
            buttonPanel.add(Box.createHorizontalStrut(padding));
        }
        buttonPanel.add(cancelButton);
        buttonPanel.add(Box.createHorizontalStrut(padding));
        buttonPanel.add(okButton);
    } else {
        buttonPanel.add(okButton);
        buttonPanel.add(Box.createHorizontalStrut(padding));
        if (includeApplyButton()) {
            buttonPanel.add(bApply);
            buttonPanel.add(Box.createHorizontalStrut(padding));
        }
        buttonPanel.add(cancelButton);
    }
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(getCenter(), BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    if (shouldSetOkAsDefault()) {
        setOkAsDefault();
    }
    if (shouldInstallEsc()) {
        Utility.installEscapeCloseOperation(this);
    }
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension)

Aggregations

FlowLayout (java.awt.FlowLayout)400 JPanel (javax.swing.JPanel)338 JLabel (javax.swing.JLabel)189 JButton (javax.swing.JButton)161 ActionEvent (java.awt.event.ActionEvent)134 BoxLayout (javax.swing.BoxLayout)129 BorderLayout (java.awt.BorderLayout)118 ActionListener (java.awt.event.ActionListener)113 Dimension (java.awt.Dimension)95 JScrollPane (javax.swing.JScrollPane)94 Container (java.awt.Container)49 GridBagLayout (java.awt.GridBagLayout)42 JTextField (javax.swing.JTextField)41 Insets (java.awt.Insets)39 GridBagConstraints (java.awt.GridBagConstraints)38 ButtonGroup (javax.swing.ButtonGroup)38 JCheckBox (javax.swing.JCheckBox)35 JTable (javax.swing.JTable)32 JmriJFrame (jmri.util.JmriJFrame)30 JSeparator (javax.swing.JSeparator)24