Search in sources :

Example 6 with BoxLayout

use of javax.swing.BoxLayout in project jdk8u_jdk by JetBrains.

the class bug8136998 method setupUI.

private void setupUI() {
    frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    comboBox = new JComboBox<>(ITEMS);
    JPanel scrollable = new JPanel();
    scrollable.setLayout(new BoxLayout(scrollable, BoxLayout.Y_AXIS));
    scrollable.add(Box.createVerticalStrut(200));
    scrollable.add(comboBox);
    scrollable.add(Box.createVerticalStrut(200));
    scrollPane = new JScrollPane(scrollable);
    frame.add(scrollPane);
    frame.setSize(100, 200);
    frame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JFrame(javax.swing.JFrame) BoxLayout(javax.swing.BoxLayout)

Example 7 with BoxLayout

use of javax.swing.BoxLayout in project pcgen by PCGen.

the class PreferencesPluginsPanel method initComponents.

private void initComponents() {
    jScrollPane1 = new JScrollPane();
    mainPanel = new JPanel();
    setLayout(new BorderLayout());
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    for (String key : pluginMap.keySet()) {
        mainPanel.add(pluginMap.get(key));
    }
    jScrollPane1.setViewportView(mainPanel);
    add(jScrollPane1, BorderLayout.CENTER);
    //$NON-NLS-1$
    add(new JLabel(LanguageBundle.getString("in_Prefs_restartInfo")), BorderLayout.SOUTH);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel)

Example 8 with BoxLayout

use of javax.swing.BoxLayout 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 9 with BoxLayout

use of javax.swing.BoxLayout in project pcgen by PCGen.

the class InfoGuidePane method initComponents.

private void initComponents() {
    mainPanel = new JPanel();
    mainPanel.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, null));
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.setPreferredSize(new Dimension(650, 450));
    setOpaque(false);
    JPanel sourcesPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc1 = new GridBagConstraints();
    gbc1.anchor = GridBagConstraints.EAST;
    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc2.gridwidth = GridBagConstraints.REMAINDER;
    gbc2.fill = GridBagConstraints.BOTH;
    sourcesPanel.add(new JLabel(LanguageBundle.getString("in_si_intro")), gbc2);
    sourcesPanel.add(new JLabel(LanguageBundle.getString("in_si_gamemode")), gbc1);
    sourcesPanel.add(gameModeLabel, gbc2);
    sourcesPanel.add(new JLabel(LanguageBundle.getString("in_si_sources")), gbc1);
    sourcesPanel.add(campaignList, gbc2);
    JEditorPane guidePane = createHtmlPane();
    guidePane.setText(LanguageBundle.getFormattedString("in_si_whatnext", Icons.New16.getImageIcon(), Icons.Open16.getImageIcon()));
    mainPanel.add(sourcesPanel);
    mainPanel.add(guidePane);
    mainPanel.add(tipPane);
    refreshDisplayedSources(null);
    JPanel outerPanel = new JPanel(new FlowLayout());
    outerPanel.add(mainPanel);
    setLayout(new BorderLayout());
    add(outerPanel, BorderLayout.CENTER);
    tipPane.setText(LanguageBundle.getFormattedString("in_si_tip", TipOfTheDayHandler.getInstance().getNextTip()));
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) BorderLayout(java.awt.BorderLayout) BoxLayout(javax.swing.BoxLayout) JEditorPane(javax.swing.JEditorPane) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Example 10 with BoxLayout

use of javax.swing.BoxLayout in project pcgen by PCGen.

the class SummaryInfoTab method initMiddlePanel.

private void initMiddlePanel(JPanel middlePanel) {
    middlePanel.setLayout(new GridLayout(2, 1));
    JPanel statsPanel = new JPanel();
    //$NON-NLS-1$
    setPanelTitle(statsPanel, LanguageBundle.getString("in_sumAbilityScores"));
    statsPanel.setLayout(new BoxLayout(statsPanel, BoxLayout.Y_AXIS));
    StatTableModel.initializeTable(statsTable);
    JScrollPane pane = new JScrollPane(statsTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) {

        @Override
        public Dimension getMaximumSize() {
            //This prevents the scroll pane from taking up more space than it needs.
            return super.getPreferredSize();
        }
    };
    pane.setBorder(BorderFactory.createEmptyBorder());
    JPanel statsBox = new JPanel();
    statsBox.setLayout(new BoxLayout(statsBox, BoxLayout.X_AXIS));
    statsBox.add(Box.createHorizontalGlue());
    statsBox.add(pane);
    statsBox.add(Box.createHorizontalGlue());
    statsPanel.add(statsBox);
    JPanel statTotalPanel = new JPanel();
    statTotalPanel.setLayout(new BoxLayout(statTotalPanel, BoxLayout.X_AXIS));
    //this makes box layout use the statTotalPanel to distribute extra space
    statTotalPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    statTotalPanel.add(Box.createHorizontalGlue());
    FontManipulation.title(statTotalLabel);
    statTotalPanel.add(statTotalLabel);
    statTotalPanel.add(statTotal);
    FontManipulation.title(modTotalLabel);
    statTotalPanel.add(modTotalLabel);
    statTotalPanel.add(modTotal);
    statTotalPanel.add(Box.createHorizontalGlue());
    //$NON-NLS-1$
    generateRollsButton.setText(LanguageBundle.getString("in_sumGenerate_Rolls"));
    statTotalPanel.add(generateRollsButton);
    //$NON-NLS-1$
    rollMethodButton.setText(LanguageBundle.getString("in_sumRoll_Method"));
    statTotalPanel.add(Box.createRigidArea(new Dimension(5, 0)));
    statTotalPanel.add(rollMethodButton);
    statTotalPanel.add(Box.createHorizontalGlue());
    statsPanel.add(statTotalPanel);
    middlePanel.add(statsPanel);
    InfoPaneHandler.initializeEditorPane(infoPane);
    pane = new JScrollPane(infoPane);
    //$NON-NLS-1$
    setPanelTitle(pane, LanguageBundle.getString("in_sumStats"));
    middlePanel.add(pane);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) BoxLayout(javax.swing.BoxLayout) Dimension(java.awt.Dimension)

Aggregations

BoxLayout (javax.swing.BoxLayout)496 JPanel (javax.swing.JPanel)423 JLabel (javax.swing.JLabel)252 ActionEvent (java.awt.event.ActionEvent)165 JButton (javax.swing.JButton)161 Dimension (java.awt.Dimension)143 ActionListener (java.awt.event.ActionListener)141 JScrollPane (javax.swing.JScrollPane)125 FlowLayout (java.awt.FlowLayout)123 BorderLayout (java.awt.BorderLayout)63 GridBagLayout (java.awt.GridBagLayout)57 ButtonGroup (javax.swing.ButtonGroup)49 Container (java.awt.Container)48 JTable (javax.swing.JTable)48 JCheckBox (javax.swing.JCheckBox)47 JmriJFrame (jmri.util.JmriJFrame)45 JSeparator (javax.swing.JSeparator)44 JTextField (javax.swing.JTextField)43 JRadioButton (javax.swing.JRadioButton)30 JComboBox (javax.swing.JComboBox)28