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