Search in sources :

Example 36 with JSpinner

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

the class NumericPanel method initializeComponents.

protected void initializeComponents() {
    super.initializeComponents();
    JPanel contentPanel = getContentPanel();
    {
        JLabel label = new JLabel("Value:");
        contentPanel.add(label, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
    }
    {
        valueSpinner = new JSpinner(new SpinnerNumberModel(new Float(0), new Float(-99999), new Float(99999), new Float(0.1f)));
        contentPanel.add(valueSpinner, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    }
    valueSpinner.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent event) {
            NumericPanel.this.value.setValue((Float) valueSpinner.getValue());
        }
    });
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) ChangeEvent(javax.swing.event.ChangeEvent) JLabel(javax.swing.JLabel) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener)

Example 37 with JSpinner

use of javax.swing.JSpinner in project binnavi by google.

the class PointerTypePanel 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 lblBaseType = new JLabel("Base type:");
    final GridBagConstraints gbc_lblBaseType = new GridBagConstraints();
    gbc_lblBaseType.anchor = GridBagConstraints.WEST;
    gbc_lblBaseType.insets = new Insets(0, 0, 5, 5);
    gbc_lblBaseType.gridx = 0;
    gbc_lblBaseType.gridy = 0;
    contentPanel.add(lblBaseType, gbc_lblBaseType);
    baseTypes = new TypeComboBox(new TypeListModel(typeManager.getTypes(), Predicates.and(new TypeListModel.ArrayTypesFilter(), 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 lblNewLabel_1 = new JLabel("Pointer level:");
    final GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
    gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
    gbc_lblNewLabel_1.gridx = 0;
    gbc_lblNewLabel_1.gridy = 1;
    contentPanel.add(lblNewLabel_1, gbc_lblNewLabel_1);
    pointerLevel = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1));
    pointerLevel.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            updatePreview();
        }
    });
    final GridBagConstraints gbc_m_pointerLevel = new GridBagConstraints();
    gbc_m_pointerLevel.anchor = GridBagConstraints.WEST;
    gbc_m_pointerLevel.insets = new Insets(0, 0, 5, 0);
    gbc_m_pointerLevel.gridx = 1;
    gbc_m_pointerLevel.gridy = 1;
    contentPanel.add(pointerLevel, gbc_m_pointerLevel);
    final JLabel lblPreview = new JLabel("Preview:");
    final GridBagConstraints gbc_lblPreview = new GridBagConstraints();
    gbc_lblPreview.insets = new Insets(0, 0, 5, 5);
    gbc_lblPreview.gridx = 0;
    gbc_lblPreview.gridy = 2;
    contentPanel.add(lblPreview, gbc_lblPreview);
    preview = new JTextArea();
    preview.setEditable(false);
    final GridBagConstraints gbc_preview = new GridBagConstraints();
    gbc_preview.insets = new Insets(0, 0, 5, 0);
    gbc_preview.fill = GridBagConstraints.BOTH;
    gbc_preview.gridx = 1;
    gbc_preview.gridy = 2;
    contentPanel.add(preview, gbc_preview);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) SpinnerNumberModel(javax.swing.SpinnerNumberModel) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener) EmptyBorder(javax.swing.border.EmptyBorder)

Example 38 with JSpinner

use of javax.swing.JSpinner in project ats-framework by Axway.

the class SwingElementLocator method findFixture.

public static ComponentFixture<? extends Component> findFixture(UiElement uiElement) {
    SwingDriverInternal driver = (SwingDriverInternal) uiElement.getUiDriver();
    ContainerFixture<?> containerFixture = (ContainerFixture<?>) driver.getActiveContainerFixture();
    Class<? extends Component> componentClass = componentsMap.get(uiElement.getClass());
    try {
        if (componentClass.equals(JButton.class)) {
            return (ComponentFixture<? extends Component>) new JButtonFixture(containerFixture.robot, (JButton) findElement(uiElement));
        } else if (componentClass.equals(JTextComponent.class)) {
            return (ComponentFixture<? extends Component>) new JTextComponentFixture(containerFixture.robot, (JTextComponent) findElement(uiElement));
        } else if (componentClass.equals(JMenuItem.class)) {
            if (uiElement.getElementProperty("path") != null) {
                return containerFixture.menuItemWithPath(uiElement.getElementProperty("path").split("[\\,\\/]+"));
            } else {
                return (ComponentFixture<? extends Component>) new JMenuItemFixture(containerFixture.robot, (JMenuItem) findElement(uiElement));
            }
        } else if (componentClass.equals(JPopupMenu.class)) {
            return (ComponentFixture<? extends Component>) new JPopupMenuFixture(containerFixture.robot, (JPopupMenu) findElement(uiElement));
        } else if (componentClass.equals(JTree.class)) {
            return (ComponentFixture<? extends Component>) new JTreeFixture(containerFixture.robot, (JTree) findElement(uiElement));
        } else if (componentClass.equals(JList.class)) {
            return (ComponentFixture<? extends Component>) new JListFixture(containerFixture.robot, (JList) findElement(uiElement));
        } else if (componentClass.equals(JCheckBox.class)) {
            return (ComponentFixture<? extends Component>) new JCheckBoxFixture(containerFixture.robot, (JCheckBox) findElement(uiElement));
        } else if (componentClass.equals(JToggleButton.class)) {
            return (ComponentFixture<? extends Component>) new JToggleButtonFixture(containerFixture.robot, (JToggleButton) findElement(uiElement));
        } else if (componentClass.equals(JComboBox.class)) {
            return (ComponentFixture<? extends Component>) new JComboBoxFixture(containerFixture.robot, (JComboBox) findElement(uiElement));
        } else if (componentClass.equals(JRadioButton.class)) {
            return (ComponentFixture<? extends Component>) new JRadioButtonFixture(containerFixture.robot, (JRadioButton) findElement(uiElement));
        } else if (componentClass.equals(JTable.class)) {
            return (ComponentFixture<? extends Component>) new JTableFixture(containerFixture.robot, (JTable) findElement(uiElement));
        } else if (componentClass.equals(JSpinner.class)) {
            return (ComponentFixture<? extends Component>) new JSpinnerFixture(containerFixture.robot, (JSpinner) findElement(uiElement));
        } else if (componentClass.equals(JTabbedPane.class)) {
            return (ComponentFixture<? extends Component>) new JTabbedPaneFixture(containerFixture.robot, (JTabbedPane) findElement(uiElement));
        } else if (componentClass.equals(JOptionPane.class)) {
            return (ComponentFixture<? extends Component>) containerFixture.optionPane();
        } else if (componentClass.equals(JLabel.class)) {
            return (ComponentFixture<? extends Component>) new JLabelFixture(containerFixture.robot, (JLabel) findElement(uiElement));
        } else if (componentClass.equals(Component.class)) {
            return new ComponentFixture<Component>(containerFixture.robot, findElement(uiElement)) {
            };
        } else if (componentClass.equals(JFileChooser.class)) {
            // TODO - might be searched by name too
            return containerFixture.fileChooser(Timeout.timeout(UiEngineConfigurator.getInstance().getElementStateChangeDelay()));
        } else {
            throw new ElementNotFoundException(uiElement.toString() + " not found. No such Fixture");
        }
    } catch (ComponentLookupException cle) {
        throw new ElementNotFoundException(uiElement.toString() + " not found.", cle);
    } catch (WaitTimedOutError exc) {
        // thrown for OptionPane search, wait for Window (BasicRobot.waitForWindow), AbstractJTableCellWriter, JTreeDriver.waitForChildrenToShowUp, each Pause wait
        throw new ElementNotFoundException(uiElement.toString() + " not found.", exc);
    }
}
Also used : JTreeFixture(org.fest.swing.fixture.JTreeFixture) JRadioButton(javax.swing.JRadioButton) SwingDriverInternal(com.axway.ats.uiengine.internal.driver.SwingDriverInternal) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JTextComponent(javax.swing.text.JTextComponent) JSpinnerFixture(org.fest.swing.fixture.JSpinnerFixture) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) WaitTimedOutError(org.fest.swing.exception.WaitTimedOutError) JLabelFixture(org.fest.swing.fixture.JLabelFixture) JTabbedPaneFixture(org.fest.swing.fixture.JTabbedPaneFixture) JButtonFixture(org.fest.swing.fixture.JButtonFixture) JToggleButtonFixture(org.fest.swing.fixture.JToggleButtonFixture) JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) JTableFixture(org.fest.swing.fixture.JTableFixture) JToggleButton(javax.swing.JToggleButton) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) ComponentFixture(org.fest.swing.fixture.ComponentFixture) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent) JMenuItem(javax.swing.JMenuItem) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) JRadioButtonFixture(org.fest.swing.fixture.JRadioButtonFixture) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) JOptionPane(javax.swing.JOptionPane) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JPopupMenuFixture(org.fest.swing.fixture.JPopupMenuFixture) JListFixture(org.fest.swing.fixture.JListFixture) ContainerFixture(org.fest.swing.fixture.ContainerFixture) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JCheckBoxFixture(org.fest.swing.fixture.JCheckBoxFixture) JList(javax.swing.JList)

Example 39 with JSpinner

use of javax.swing.JSpinner in project jadx by skylot.

the class JadxSettingsWindow method makeDeobfuscationGroup.

private SettingsGroup makeDeobfuscationGroup() {
    JCheckBox deobfOn = new JCheckBox();
    deobfOn.setSelected(settings.isDeobfuscationOn());
    deobfOn.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            settings.setDeobfuscationOn(e.getStateChange() == ItemEvent.SELECTED);
            needReload();
        }
    });
    JCheckBox deobfForce = new JCheckBox();
    deobfForce.setSelected(settings.isDeobfuscationForceSave());
    deobfForce.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            settings.setDeobfuscationForceSave(e.getStateChange() == ItemEvent.SELECTED);
            needReload();
        }
    });
    final JSpinner minLen = new JSpinner();
    minLen.setValue(settings.getDeobfuscationMinLength());
    minLen.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            settings.setDeobfuscationMinLength((Integer) minLen.getValue());
            needReload();
        }
    });
    final JSpinner maxLen = new JSpinner();
    maxLen.setValue(settings.getDeobfuscationMaxLength());
    maxLen.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            settings.setDeobfuscationMaxLength((Integer) maxLen.getValue());
            needReload();
        }
    });
    JCheckBox deobfSourceAlias = new JCheckBox();
    deobfSourceAlias.setSelected(settings.useSourceNameAsClassAlias());
    deobfSourceAlias.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            settings.setUseSourceNameAsClassAlias(e.getStateChange() == ItemEvent.SELECTED);
            needReload();
        }
    });
    SettingsGroup deobfGroup = new SettingsGroup(NLS.str("preferences.deobfuscation"));
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_on"), deobfOn);
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_force"), deobfForce);
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_min_len"), minLen);
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_max_len"), maxLen);
    deobfGroup.addRow(NLS.str("preferences.deobfuscation_source_alias"), deobfSourceAlias);
    deobfGroup.end();
    return deobfGroup;
}
Also used : JCheckBox(javax.swing.JCheckBox) ItemEvent(java.awt.event.ItemEvent) ChangeEvent(javax.swing.event.ChangeEvent) JSpinner(javax.swing.JSpinner) ItemListener(java.awt.event.ItemListener) ChangeListener(javax.swing.event.ChangeListener)

Example 40 with JSpinner

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

the class BeanGrouper method getFreqSpinner.

/**
	 * Initializes the TextField that will allow to input the desired Frequency for the Sampling Group.<br>
	 * By default the value is 10 Hz.<br>
	 * Also checks for its correctness when the value changes.
	 * @return javax.swing.JTextField Reference to the Text Field containing the number.
	 */
private JSpinner getFreqSpinner() {
    if (freqSpinner == null) {
        freqSpinner = new JSpinner();
        freqSpinner.setToolTipText("How often, in herz, will the sampling occur.");
        freqSpinner.setModel(new SpinnerNumberModel(1, 0.1, 20.0, 0.1));
        freqSpinner.addChangeListener(new ChangeListener() {

            public void stateChanged(ChangeEvent e) {
                for (DataPrinter dp : samplers) {
                    double freq = ((SpinnerNumberModel) freqSpinner.getModel()).getNumber().doubleValue();
                    dp.setFrequency(freq);
                }
            }
        });
    }
    return freqSpinner;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) ChangeEvent(javax.swing.event.ChangeEvent) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

JSpinner (javax.swing.JSpinner)76 SpinnerNumberModel (javax.swing.SpinnerNumberModel)61 JLabel (javax.swing.JLabel)47 JPanel (javax.swing.JPanel)41 ActionEvent (java.awt.event.ActionEvent)28 ActionListener (java.awt.event.ActionListener)27 JCheckBox (javax.swing.JCheckBox)22 JRadioButton (javax.swing.JRadioButton)21 GridBagConstraints (java.awt.GridBagConstraints)18 Insets (java.awt.Insets)18 ChangeEvent (javax.swing.event.ChangeEvent)18 GridBagLayout (java.awt.GridBagLayout)17 JButton (javax.swing.JButton)15 Dimension (java.awt.Dimension)13 ChangeListener (javax.swing.event.ChangeListener)13 ButtonGroup (javax.swing.ButtonGroup)12 BorderLayout (java.awt.BorderLayout)11 JTextField (javax.swing.JTextField)11 JScrollPane (javax.swing.JScrollPane)10 JMenuItem (javax.swing.JMenuItem)8