use of javax.swing.SpinnerNumberModel in project libgdx by libgdx.
the class Hiero method initializeComponents.
private void initializeComponents() {
getContentPane().setLayout(new GridBagLayout());
JPanel leftSidePanel = new JPanel();
leftSidePanel.setLayout(new GridBagLayout());
getContentPane().add(leftSidePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
{
JPanel fontPanel = new JPanel();
leftSidePanel.add(fontPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
fontPanel.setLayout(new GridBagLayout());
fontPanel.setBorder(BorderFactory.createTitledBorder("Font"));
{
fontSizeSpinner = new JSpinner(new SpinnerNumberModel(32, 0, 256, 1));
fontPanel.add(fontSizeSpinner, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
((JSpinner.DefaultEditor) fontSizeSpinner.getEditor()).getTextField().setColumns(2);
}
{
JScrollPane fontScroll = new JScrollPane();
fontPanel.add(fontScroll, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
{
fontListModel = new DefaultComboBoxModel(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
fontList = new JList();
fontScroll.setViewportView(fontList);
fontList.setModel(fontListModel);
fontList.setVisibleRowCount(6);
fontList.setSelectedIndex(0);
fontScroll.setMinimumSize(new Dimension(220, fontList.getPreferredScrollableViewportSize().height));
}
}
{
systemFontRadio = new JRadioButton("System:", true);
fontPanel.add(systemFontRadio, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
systemFontRadio.setMargin(new Insets(0, 0, 0, 0));
}
{
fontFileRadio = new JRadioButton("File:");
fontPanel.add(fontFileRadio, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
fontFileRadio.setMargin(new Insets(0, 0, 0, 0));
}
{
fontFileText = new JTextField();
fontPanel.add(fontFileText, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
}
{
fontPanel.add(new JLabel("Size:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
unicodePanel = new JPanel(new GridBagLayout());
fontPanel.add(unicodePanel, new GridBagConstraints(2, 3, 2, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
{
boldCheckBox = new JCheckBox("Bold");
unicodePanel.add(boldCheckBox, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
italicCheckBox = new JCheckBox("Italic");
unicodePanel.add(italicCheckBox, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
}
{
bitmapPanel = new JPanel(new GridBagLayout());
fontPanel.add(bitmapPanel, new GridBagConstraints(2, 3, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
{
bitmapPanel.add(new JLabel("Gamma:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
gammaSpinner = new JSpinner(new SpinnerNumberModel(1.8f, 0, 30, 0.01));
((JSpinner.DefaultEditor) gammaSpinner.getEditor()).getTextField().setColumns(2);
bitmapPanel.add(gammaSpinner, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
}
{
monoCheckBox = new JCheckBox("Mono");
bitmapPanel.add(monoCheckBox, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
}
{
browseButton = new JButton("...");
fontPanel.add(browseButton, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
browseButton.setMargin(new Insets(0, 0, 0, 0));
}
{
fontPanel.add(new JLabel("Rendering:"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
JPanel renderingPanel = new JPanel(new GridBagLayout());
fontPanel.add(renderingPanel, new GridBagConstraints(1, 4, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
{
freeTypeRadio = new JRadioButton("FreeType");
renderingPanel.add(freeTypeRadio, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
javaRadio = new JRadioButton("Java");
renderingPanel.add(javaRadio, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
nativeRadio = new JRadioButton("Native");
renderingPanel.add(nativeRadio, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
}
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(systemFontRadio);
buttonGroup.add(fontFileRadio);
buttonGroup = new ButtonGroup();
buttonGroup.add(freeTypeRadio);
buttonGroup.add(javaRadio);
buttonGroup.add(nativeRadio);
freeTypeRadio.setSelected(true);
}
{
JPanel samplePanel = new JPanel();
leftSidePanel.add(samplePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 5, 5), 0, 0));
samplePanel.setLayout(new GridBagLayout());
samplePanel.setBorder(BorderFactory.createTitledBorder("Sample Text"));
{
JScrollPane textScroll = new JScrollPane();
samplePanel.add(textScroll, new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
{
sampleTextPane = new JTextPane();
textScroll.setViewportView(sampleTextPane);
}
}
{
sampleNeheButton = new JButton();
sampleNeheButton.setText("NEHE");
samplePanel.add(sampleNeheButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
sampleAsciiButton = new JButton();
sampleAsciiButton.setText("ASCII");
samplePanel.add(sampleAsciiButton, new GridBagConstraints(3, 1, 1, 1, 0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
sampleExtendedButton = new JButton();
sampleExtendedButton.setText("Extended");
samplePanel.add(sampleExtendedButton, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
}
{
JPanel renderingPanel = new JPanel();
leftSidePanel.add(renderingPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
renderingPanel.setBorder(BorderFactory.createTitledBorder("Rendering"));
renderingPanel.setLayout(new GridBagLayout());
{
JPanel wrapperPanel = new JPanel();
renderingPanel.add(wrapperPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
wrapperPanel.setLayout(new BorderLayout());
wrapperPanel.setBackground(java.awt.Color.white);
{
gamePanel = new JPanel();
wrapperPanel.add(gamePanel);
gamePanel.setLayout(new BorderLayout());
gamePanel.setBackground(java.awt.Color.white);
}
}
{
glyphCachePanel = new JPanel() {
private int maxWidth;
public Dimension getPreferredSize() {
// Keep glyphCachePanel width from ever going down so the CanvasGameContainer doesn't change sizes and flicker.
Dimension size = super.getPreferredSize();
maxWidth = Math.max(maxWidth, size.width);
size.width = maxWidth;
return size;
}
};
glyphCachePanel.setVisible(false);
renderingPanel.add(glyphCachePanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
glyphCachePanel.setLayout(new GridBagLayout());
{
glyphCachePanel.add(new JLabel("Glyphs:"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
glyphCachePanel.add(new JLabel("Pages:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
glyphCachePanel.add(new JLabel("Page width:"), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
glyphCachePanel.add(new JLabel("Page height:"), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
glyphPageWidthCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] { new Integer(32), new Integer(64), new Integer(128), new Integer(256), new Integer(512), new Integer(1024), new Integer(2048) }));
glyphCachePanel.add(glyphPageWidthCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
glyphPageWidthCombo.setSelectedIndex(4);
}
{
glyphPageHeightCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] { new Integer(32), new Integer(64), new Integer(128), new Integer(256), new Integer(512), new Integer(1024), new Integer(2048) }));
glyphCachePanel.add(glyphPageHeightCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
glyphPageHeightCombo.setSelectedIndex(4);
}
{
resetCacheButton = new JButton("Reset Cache");
glyphCachePanel.add(resetCacheButton, new GridBagConstraints(0, 6, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
glyphPagesTotalLabel = new JLabel("1");
glyphCachePanel.add(glyphPagesTotalLabel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
glyphsTotalLabel = new JLabel("0");
glyphCachePanel.add(glyphsTotalLabel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
glyphPageComboModel = new DefaultComboBoxModel();
glyphPageCombo = new JComboBox();
glyphCachePanel.add(glyphPageCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
glyphPageCombo.setModel(glyphPageComboModel);
}
{
glyphCachePanel.add(new JLabel("View:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
}
{
JPanel radioButtonsPanel = new JPanel();
renderingPanel.add(radioButtonsPanel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
radioButtonsPanel.setLayout(new GridBagLayout());
{
sampleTextRadio = new JRadioButton("Sample text");
radioButtonsPanel.add(sampleTextRadio, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
sampleTextRadio.setSelected(true);
}
{
glyphCacheRadio = new JRadioButton("Glyph cache");
radioButtonsPanel.add(glyphCacheRadio, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
{
radioButtonsPanel.add(new JLabel("Background:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
}
{
backgroundColorLabel = new JLabel();
radioButtonsPanel.add(backgroundColorLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
}
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(glyphCacheRadio);
buttonGroup.add(sampleTextRadio);
}
}
JPanel rightSidePanel = new JPanel();
rightSidePanel.setLayout(new GridBagLayout());
getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
{
JPanel paddingPanel = new JPanel();
paddingPanel.setLayout(new GridBagLayout());
rightSidePanel.add(paddingPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
paddingPanel.setBorder(BorderFactory.createTitledBorder("Padding"));
{
padTopSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
paddingPanel.add(padTopSpinner, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
((JSpinner.DefaultEditor) padTopSpinner.getEditor()).getTextField().setColumns(2);
}
{
padRightSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
paddingPanel.add(padRightSpinner, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
((JSpinner.DefaultEditor) padRightSpinner.getEditor()).getTextField().setColumns(2);
}
{
padLeftSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
paddingPanel.add(padLeftSpinner, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0));
((JSpinner.DefaultEditor) padLeftSpinner.getEditor()).getTextField().setColumns(2);
}
{
padBottomSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
paddingPanel.add(padBottomSpinner, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
((JSpinner.DefaultEditor) padBottomSpinner.getEditor()).getTextField().setColumns(2);
}
{
JPanel advancePanel = new JPanel();
FlowLayout advancePanelLayout = new FlowLayout();
advancePanel.setLayout(advancePanelLayout);
paddingPanel.add(advancePanel, new GridBagConstraints(0, 4, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
{
advancePanel.add(new JLabel("X:"));
}
{
padAdvanceXSpinner = new JSpinner(new SpinnerNumberModel(-2, -999, 999, 1));
advancePanel.add(padAdvanceXSpinner);
((JSpinner.DefaultEditor) padAdvanceXSpinner.getEditor()).getTextField().setColumns(2);
}
{
advancePanel.add(new JLabel("Y:"));
}
{
padAdvanceYSpinner = new JSpinner(new SpinnerNumberModel(-2, -999, 999, 1));
advancePanel.add(padAdvanceYSpinner);
((JSpinner.DefaultEditor) padAdvanceYSpinner.getEditor()).getTextField().setColumns(2);
}
}
}
{
effectsPanel = new JPanel();
effectsPanel.setLayout(new GridBagLayout());
rightSidePanel.add(effectsPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 5, 5), 0, 0));
effectsPanel.setBorder(BorderFactory.createTitledBorder("Effects"));
effectsPanel.setMinimumSize(new Dimension(210, 1));
{
effectsScroll = new JScrollPane();
effectsPanel.add(effectsScroll, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0));
{
effectsListModel = new DefaultComboBoxModel();
effectsList = new JList();
effectsScroll.setViewportView(effectsList);
effectsList.setModel(effectsListModel);
effectsList.setVisibleRowCount(7);
effectsScroll.setMinimumSize(effectsList.getPreferredScrollableViewportSize());
}
}
{
addEffectButton = new JButton("Add");
effectsPanel.add(addEffectButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 6, 5), 0, 0));
addEffectButton.setEnabled(false);
}
{
appliedEffectsScroll = new JScrollPane();
effectsPanel.add(appliedEffectsScroll, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
appliedEffectsScroll.setBorder(new EmptyBorder(0, 0, 0, 0));
appliedEffectsScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
{
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
appliedEffectsScroll.setViewportView(panel);
{
appliedEffectsPanel = new JPanel();
appliedEffectsPanel.setLayout(new GridBagLayout());
panel.add(appliedEffectsPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
appliedEffectsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, java.awt.Color.black));
}
}
}
}
}
use of javax.swing.SpinnerNumberModel in project gephi-plugins-bootcamp by gephi.
the class TopNodesFilterPanel method setup.
public void setup(TopNodesFilter f) {
this.filter = f;
final SpinnerNumberModel model = new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1);
topSpinner.setModel(model);
model.addChangeListener(WeakListeners.change(this, model));
}
use of javax.swing.SpinnerNumberModel in project gephi by gephi.
the class PlaySettingsDialog method setup.
public void setup(TimelineModel model) {
this.model = model;
this.controller = Lookup.getDefault().lookup(TimelineController.class);
int delay = model.getPlayDelay();
SpinnerNumberModel delayModel = new SpinnerNumberModel(delay, 10, Integer.MAX_VALUE, 50);
delaySpinner.setModel(delayModel);
double step = model.getPlayStep() * 100;
SpinnerNumberModel stepModel = new SpinnerNumberModel(Math.abs(step), 0.00001, 100, 1);
stepSizeSpinner.setModel(stepModel);
if (model.getPlayMode().equals(TimelineModel.PlayMode.ONE_BOUND)) {
oneBoundRadio.setSelected(true);
} else {
twoBoundsRadio.setSelected(true);
}
if (step < 0) {
backwardCheckbox.setSelected(true);
}
}
use of javax.swing.SpinnerNumberModel in project binnavi by google.
the class ArrayTypePanel method createControls.
private void createControls() {
setLayout(new BorderLayout());
final JPanel contentPanel = new JPanel();
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
add(contentPanel, BorderLayout.CENTER);
final GridBagLayout gbl_m_contentPanel = new GridBagLayout();
gbl_m_contentPanel.columnWidths = new int[] { 0, 0, 0 };
gbl_m_contentPanel.rowHeights = new int[] { 0, 0, 0, 0, 0 };
gbl_m_contentPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
gbl_m_contentPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
contentPanel.setLayout(gbl_m_contentPanel);
final JLabel lblSize = new JLabel("Number of elements:");
final GridBagConstraints gbc_lblSize = new GridBagConstraints();
gbc_lblSize.anchor = GridBagConstraints.WEST;
gbc_lblSize.insets = new Insets(0, 0, 5, 5);
gbc_lblSize.gridx = 0;
gbc_lblSize.gridy = 1;
contentPanel.add(lblSize, gbc_lblSize);
numberElements = new JSpinner(new SpinnerNumberModel(1, 1, Integer.MAX_VALUE, 1));
numberElements.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
updatePreview();
}
});
final GridBagConstraints gbc_numberElements = new GridBagConstraints();
gbc_numberElements.anchor = GridBagConstraints.WEST;
gbc_numberElements.insets = new Insets(0, 0, 5, 0);
gbc_numberElements.gridx = 1;
gbc_numberElements.gridy = 1;
contentPanel.add(numberElements, gbc_numberElements);
final JLabel lblFillWith = new JLabel("Element type:");
final GridBagConstraints gbc_lblFillWith = new GridBagConstraints();
gbc_lblFillWith.anchor = GridBagConstraints.WEST;
gbc_lblFillWith.insets = new Insets(0, 0, 5, 5);
gbc_lblFillWith.gridx = 0;
gbc_lblFillWith.gridy = 0;
contentPanel.add(lblFillWith, gbc_lblFillWith);
baseTypes = new TypeComboBox(new TypeListModel(typeManager.getTypes(), new TypeListModel.PrototypesFilter()));
baseTypes.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
updatePreview();
}
});
final GridBagConstraints gbc_baseTypes = new GridBagConstraints();
gbc_baseTypes.insets = new Insets(0, 0, 5, 0);
gbc_baseTypes.fill = GridBagConstraints.HORIZONTAL;
gbc_baseTypes.gridx = 1;
gbc_baseTypes.gridy = 0;
contentPanel.add(baseTypes, gbc_baseTypes);
final JLabel lblPreview = new JLabel("Preview:");
final GridBagConstraints gbc_lblPreview = new GridBagConstraints();
gbc_lblPreview.anchor = GridBagConstraints.WEST;
gbc_lblPreview.insets = new Insets(0, 0, 5, 5);
gbc_lblPreview.gridx = 0;
gbc_lblPreview.gridy = 2;
contentPanel.add(lblPreview, gbc_lblPreview);
final JScrollPane scrollPane = new JScrollPane();
scrollPane.setBorder(null);
final GridBagConstraints gbc_scrollPane = new GridBagConstraints();
gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
gbc_scrollPane.fill = GridBagConstraints.BOTH;
gbc_scrollPane.gridx = 1;
gbc_scrollPane.gridy = 2;
contentPanel.add(scrollPane, gbc_scrollPane);
preview = new JTextArea();
preview.setEditable(false);
scrollPane.setViewportView(preview);
}
use of javax.swing.SpinnerNumberModel in project pcgen by PCGen.
the class PostLevelUpDialog method initComponents.
private void initComponents() {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
JTable table = new JTable(tableModel) {
@Override
public TableCellEditor getCellEditor(int row, int column) {
if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {
//TODO: the max roll should be calculated in a different manner
String hd = levels.getClassTaken(levels.getElementAt(row + oldLevel)).getHD();
int max = NumberUtils.toInt(hd);
return new SpinnerEditor(new SpinnerNumberModel(1, 1, max, 1));
}
return super.getCellEditor(row, column);
}
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {
return new SpinnerRenderer();
}
return super.getCellRenderer(row, column);
}
};
table.setCellSelectionEnabled(false);
table.setRowHeight(new JSpinner().getPreferredSize().height);
JTableHeader header = table.getTableHeader();
header.setReorderingAllowed(false);
JScrollPane scrollPane = new JScrollPane(table);
pane.add(scrollPane, BorderLayout.CENTER);
Box box = Box.createHorizontalBox();
box.add(Box.createHorizontalGlue());
//$NON-NLS-1$
JButton button = new JButton(LanguageBundle.getString("in_close"));
//$NON-NLS-1$
button.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
//$NON-NLS-1$
button.setActionCommand("Close");
button.addActionListener(this);
box.add(button);
pane.add(box, BorderLayout.SOUTH);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
//Make sure to remove the listeners so that the garbage collector can
//dispose of this dialog and prevent a memory leak
levels.removeHitPointListener(tableModel);
}
});
Utility.installEscapeCloseOperation(this);
}
Aggregations