Search in sources :

Example 6 with JSpinner

use of javax.swing.JSpinner 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);
}
Also used : JScrollPane(javax.swing.JScrollPane) SpinnerEditor(pcgen.gui2.util.table.TableCellUtilities.SpinnerEditor) JButton(javax.swing.JButton) JTableHeader(javax.swing.table.JTableHeader) WindowAdapter(java.awt.event.WindowAdapter) Box(javax.swing.Box) SpinnerRenderer(pcgen.gui2.util.table.TableCellUtilities.SpinnerRenderer) SpinnerNumberModel(javax.swing.SpinnerNumberModel) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) WindowEvent(java.awt.event.WindowEvent) JSpinner(javax.swing.JSpinner)

Example 7 with JSpinner

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

the class SkillInfoTab method initComponents.

private void initComponents() {
    setOrientation(VERTICAL_SPLIT);
    setResizeWeight(0.70);
    JSpinner spinner = new JSpinner();
    //$NON-NLS-1$
    spinner.setEditor(new JSpinner.NumberEditor(spinner, "#0.#"));
    skillTable.setDefaultRenderer(Float.class, new SpinnerRenderer(spinner));
    skillTable.setDefaultRenderer(Integer.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    skillTable.setDefaultRenderer(String.class, new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    skillTable.setRowHeight(26);
    FilterBar<CharacterFacade, SkillFacade> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    //$NON-NLS-1$
    cFilterButton.setText(LanguageBundle.getString("in_classString"));
    cFilterButton.setEnabled(false);
    filterBar.addDisplayableFilter(cFilterButton);
    //$NON-NLS-1$
    trainedFilterButton.setText(LanguageBundle.getString("in_trained"));
    trainedFilterButton.setEnabled(false);
    filterBar.addDisplayableFilter(trainedFilterButton);
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(skillTable, filterBar);
    availPanel.setPreferredSize(new Dimension(650, 300));
    JScrollPane tableScrollPane;
    JPanel tablePanel = new JPanel(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    constraints.fill = java.awt.GridBagConstraints.BOTH;
    constraints.weightx = 1.0;
    constraints.ipady = 0;
    constraints.weighty = 1.0;
    SkillPointTableModel.initializeTable(skillpointTable);
    tableScrollPane = new JScrollPane(skillpointTable);
    tablePanel.add(tableScrollPane, constraints);
    htmlPane.setOpaque(false);
    htmlPane.setEditable(false);
    htmlPane.setFocusable(false);
    //$NON-NLS-1$
    htmlPane.setContentType("text/html");
    skillFilterBox.setRenderer(new DefaultListCellRenderer());
    JScrollPane selScrollPane = new JScrollPane(htmlPane);
    JPanel skillPanel = new JPanel(new BorderLayout());
    skillPanel.add(skillFilterBox, BorderLayout.NORTH);
    skillPanel.add(selScrollPane, BorderLayout.CENTER);
    selScrollPane.setPreferredSize(new Dimension(530, 300));
    FlippingSplitPane topPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, availPanel, skillPanel, "SkillTop");
    setTopComponent(topPane);
    FlippingSplitPane bottomPane = new FlippingSplitPane(JSplitPane.HORIZONTAL_SPLIT, "SkillBottom");
    bottomPane.setLeftComponent(tablePanel);
    tablePanel.setPreferredSize(new Dimension(650, 100));
    bottomPane.setRightComponent(infoPane);
    infoPane.setPreferredSize(new Dimension(530, 100));
    setBottomComponent(bottomPane);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) SkillFacade(pcgen.facade.core.SkillFacade) Dimension(java.awt.Dimension) SpinnerRenderer(pcgen.gui2.util.table.TableCellUtilities.SpinnerRenderer) CharacterFacade(pcgen.facade.core.CharacterFacade) FlippingSplitPane(pcgen.gui2.tools.FlippingSplitPane) TableCellUtilities(pcgen.gui2.util.table.TableCellUtilities) FilterBar(pcgen.gui2.filter.FilterBar) BorderLayout(java.awt.BorderLayout) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) JSpinner(javax.swing.JSpinner) SearchFilterPanel(pcgen.gui2.filter.SearchFilterPanel)

Example 8 with JSpinner

use of javax.swing.JSpinner in project ACS by ACS-Community.

the class BeanGrouper method getTimeWindowSpinner.

/**
	 * Initializes the TextField that will allow to input the desired Time Window for the Sampling Group.<br>
	 * By default the value is 10, which means 10 minutes.<br>
	 * Also checks for its correctness when the value changes.
	 * @return javax.swing.JTextField Reference to the Text Field containing the number.
	 */
private JSpinner getTimeWindowSpinner() {
    if (timeWindowSpinner == null) {
        timeWindowSpinner = new JSpinner();
        timeWindowSpinner.setToolTipText("How much data, expressed in seconds, will the trend present in the graph.");
        timeWindowSpinner.setModel(new SpinnerNumberModel(5, 1, 900, 1));
        timeWindowSpinner.addChangeListener(new ChangeListener() {

            public void stateChanged(ChangeEvent e) {
                setTimeWindow();
            }
        });
    }
    return timeWindowSpinner;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) ChangeEvent(javax.swing.event.ChangeEvent) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener)

Example 9 with JSpinner

use of javax.swing.JSpinner in project JMRI by JMRI.

the class GuiLafConfigPane method doToolTipDismissDelay.

public void doToolTipDismissDelay(JPanel panel) {
    GuiLafPreferencesManager manager = InstanceManager.getDefault(GuiLafPreferencesManager.class);
    JLabel toolTipDismissDelayLabel = new JLabel(ConfigBundle.getMessage("GUIToolTipDismissDelay"));
    toolTipDismissDelaySpinner = new JSpinner(new SpinnerNumberModel(manager.getToolTipDismissDelay() / 1000, MIN_TOOLTIP_TIME, MAX_TOOLTIP_TIME, 1));
    this.toolTipDismissDelaySpinner.addChangeListener((ChangeEvent e) -> {
        // convert to milliseconds from seconds
        manager.setToolTipDismissDelay((int) toolTipDismissDelaySpinner.getValue() * 1000);
    });
    this.toolTipDismissDelaySpinner.setToolTipText(MessageFormat.format(ConfigBundle.getMessage("GUIToolTipDismissDelayToolTip"), MIN_TOOLTIP_TIME, MAX_TOOLTIP_TIME));
    toolTipDismissDelayLabel.setToolTipText(this.toolTipDismissDelaySpinner.getToolTipText());
    JLabel toolTipDismissDelayUoM = new JLabel(ConfigBundle.getMessage("GUIToolTipDismissDelayUoM"));
    toolTipDismissDelayUoM.setToolTipText(this.toolTipDismissDelaySpinner.getToolTipText());
    panel.add(toolTipDismissDelayLabel);
    panel.add(toolTipDismissDelaySpinner);
    panel.add(toolTipDismissDelayUoM);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) GuiLafPreferencesManager(apps.gui.GuiLafPreferencesManager) ChangeEvent(javax.swing.event.ChangeEvent) JLabel(javax.swing.JLabel) JSpinner(javax.swing.JSpinner)

Example 10 with JSpinner

use of javax.swing.JSpinner in project JMRI by JMRI.

the class MemoryItemPanel method makeDndIconPanel.

@Override
protected void makeDndIconPanel(java.util.HashMap<String, NamedIcon> iconMap, String displayKey) {
    if (_update) {
        return;
    }
    JPanel panel = new JPanel();
    panel.setLayout(new java.awt.GridBagLayout());
    java.awt.GridBagConstraints c = new java.awt.GridBagConstraints();
    c.gridwidth = 1;
    c.gridheight = 1;
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = java.awt.GridBagConstraints.CENTER;
    c.weightx = 1.0;
    panel.add(new JLabel(Bundle.getMessage("ReadWriteMemory")), c);
    c.gridy = 1;
    _writeMem = new MemoryInputIcon(5, _editor);
    //        JPanel p0 = makeDragIcon(_writeMem, Type.READWRITE);
    panel.add(makeDragIcon(_writeMem, Type.READWRITE), c);
    _spinner = new JSpinner(new SpinnerNumberModel(0, 0, 100, 1));
    JTextField field = ((JSpinner.DefaultEditor) _spinner.getEditor()).getTextField();
    field.setColumns(2);
    field.setText("5");
    _spinner.setMaximumSize(_spinner.getPreferredSize());
    _spinner.addChangeListener(this);
    c.gridy = 2;
    panel.add(_spinner, c);
    c.gridy = 3;
    c.anchor = java.awt.GridBagConstraints.NORTH;
    panel.add(new JLabel(Bundle.getMessage("NumColsLabel")), c);
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = java.awt.GridBagConstraints.CENTER;
    panel.add(new JLabel(Bundle.getMessage("ReadMemory")), c);
    c.gridy = 1;
    _readMem = new MemoryIcon(NamedIcon.getIconByName("resources/icons/misc/X-red.gif"), _editor);
    panel.add(makeDragIcon(_readMem, Type.READONLY), c);
    c.gridx = 2;
    c.gridy = 0;
    panel.add(new JLabel(Bundle.getMessage("SpinnerMemory")), c);
    c.gridy = 1;
    _spinMem = new MemorySpinnerIcon(_editor);
    panel.add(makeDragIcon(_spinMem, Type.SPINNER), c);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 4;
    panel.add(new JLabel(Bundle.getMessage("ComboMemory")), c);
    c.gridy = 3;
    _comboMem = new MemoryComboIcon(_editor, null);
    panel.add(makeDragIcon(_comboMem, Type.COMBO), c);
    _dragIconPanel = panel;
    _dragIconPanel.invalidate();
}
Also used : JPanel(javax.swing.JPanel) MemoryIcon(jmri.jmrit.display.MemoryIcon) MemorySpinnerIcon(jmri.jmrit.display.MemorySpinnerIcon) JLabel(javax.swing.JLabel) MemoryInputIcon(jmri.jmrit.display.MemoryInputIcon) JTextField(javax.swing.JTextField) MemoryComboIcon(jmri.jmrit.display.MemoryComboIcon) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JSpinner(javax.swing.JSpinner)

Aggregations

JSpinner (javax.swing.JSpinner)50 SpinnerNumberModel (javax.swing.SpinnerNumberModel)38 JLabel (javax.swing.JLabel)33 JPanel (javax.swing.JPanel)27 JCheckBox (javax.swing.JCheckBox)15 ChangeEvent (javax.swing.event.ChangeEvent)15 JButton (javax.swing.JButton)12 JRadioButton (javax.swing.JRadioButton)12 ActionEvent (java.awt.event.ActionEvent)10 JScrollPane (javax.swing.JScrollPane)10 ChangeListener (javax.swing.event.ChangeListener)10 BorderLayout (java.awt.BorderLayout)9 ActionListener (java.awt.event.ActionListener)9 GridBagConstraints (java.awt.GridBagConstraints)7 Insets (java.awt.Insets)7 FormLayout (com.jgoodies.forms.layout.FormLayout)6 JTable (javax.swing.JTable)6 Dimension (java.awt.Dimension)5 GridBagLayout (java.awt.GridBagLayout)5 ItemEvent (java.awt.event.ItemEvent)5