Search in sources :

Example 26 with Dimension

use of java.awt.Dimension 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)

Example 27 with Dimension

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

the class NoteInfoPane method initComponents.

private void initComponents() {
    setLayout(new BorderLayout());
    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    //$NON-NLS-1$
    hbox.add(new JLabel(LanguageBundle.getString("in_descNoteName")));
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(nameField);
    nameField.setText(name);
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(removeButton);
    hbox.add(Box.createHorizontalGlue());
    noteField.setLineWrap(true);
    noteField.setWrapStyleWord(true);
    add(hbox, BorderLayout.NORTH);
    JScrollPane pane = new JScrollPane(noteField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    add(pane, BorderLayout.CENTER);
}
Also used : JScrollPane(javax.swing.JScrollPane) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) Box(javax.swing.Box) Dimension(java.awt.Dimension)

Example 28 with Dimension

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

the class EquipmentModels method prepareScrollPane.

private static JScrollPane prepareScrollPane(JTable table) {
    JScrollPane pane = new JScrollPane(table);
    Dimension size = table.getPreferredSize();
    // account for the header which has not been prepared yet
    size.height += 30;
    final int decorationHeight = 80;
    final int decorationWidth = 70;
    Rectangle screenBounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
    if (size.height > screenBounds.height - decorationHeight) {
        size.height = screenBounds.height - decorationHeight;
    }
    if (size.width > screenBounds.width - decorationWidth) {
        size.width = screenBounds.width - decorationWidth;
    }
    pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    pane.setPreferredSize(size);
    return pane;
}
Also used : JScrollPane(javax.swing.JScrollPane) Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension)

Example 29 with Dimension

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

the class PortraitInfoPane method initComponents.

private void initComponents() {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    Utility.buildConstraints(gbc, 0, 0, 2, 1, 0, 0);
    panel.add(new JLabel(LanguageBundle.getString("in_largePortrait")), gbc);
    Utility.buildConstraints(gbc, 0, 1, 2, 1, 0, 0);
    panel.add(portraitPane, gbc);
    Utility.buildConstraints(gbc, 0, 2, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST);
    panel.add(loadButton, gbc);
    Utility.buildConstraints(gbc, 1, 2, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST);
    panel.add(clearButton, gbc);
    Utility.buildConstraints(gbc, 2, 1, 1, 1, 0, 0, GridBagConstraints.VERTICAL, GridBagConstraints.CENTER);
    zoomSlider.setInverted(true);
    zoomSlider.setPreferredSize(new Dimension(20, 10));
    panel.add(zoomSlider, gbc);
    Utility.buildConstraints(gbc, 3, 0, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    panel.add(new JLabel(LanguageBundle.getString("in_thumbnailPortrait")), gbc);
    Utility.buildConstraints(gbc, 3, 1, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTH);
    panel.add(tnPane, gbc);
    this.setViewportView(panel);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Example 30 with Dimension

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

the class PortraitPane method getPreferredSize.

@Override
public Dimension getPreferredSize() {
    Insets insets = getInsets();
    int width = 0;
    int height = 0;
    if (insets != null) {
        width += insets.left + insets.right;
        height += insets.top + insets.bottom;
    }
    if (portrait != null) {
        if (scale < 1) {
            width += (int) (scale * portrait.getWidth());
            height += (int) (scale * portrait.getHeight());
        } else {
            width += portrait.getWidth();
            height += portrait.getHeight();
        }
    }
    return new Dimension(width, height);
}
Also used : Insets(java.awt.Insets) Dimension(java.awt.Dimension)

Aggregations

Dimension (java.awt.Dimension)3966 JPanel (javax.swing.JPanel)1083 JLabel (javax.swing.JLabel)737 Point (java.awt.Point)676 JButton (javax.swing.JButton)667 ActionEvent (java.awt.event.ActionEvent)642 ActionListener (java.awt.event.ActionListener)581 JScrollPane (javax.swing.JScrollPane)554 BorderLayout (java.awt.BorderLayout)490 Insets (java.awt.Insets)403 BoxLayout (javax.swing.BoxLayout)333 GridBagLayout (java.awt.GridBagLayout)308 GridBagConstraints (java.awt.GridBagConstraints)262 FlowLayout (java.awt.FlowLayout)240 JTextField (javax.swing.JTextField)231 ImageIcon (javax.swing.ImageIcon)216 Component (java.awt.Component)214 Color (java.awt.Color)202 ChangeEvent (javax.swing.event.ChangeEvent)200 ChangeListener (javax.swing.event.ChangeListener)198