Java Code Examples for javax.swing.JSpinner#getValue()

The following examples show how to use javax.swing.JSpinner#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScriptInspector.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addToSet(JSpinner spinner)
{
	int script = (Integer) spinner.getValue();
	Set<Integer> set = getSet();
	set.add(script);
	refreshList();
	spinner.setValue(0);
}
 
Example 2
Source File: ScriptInspector.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void addToSet(JSpinner spinner)
{
	int script = (Integer) spinner.getValue();
	Set<Integer> set = getSet();
	set.add(script);
	refreshList();
	spinner.setValue(0);
}
 
Example 3
Source File: PaletteEditor.java    From lsdpatch with MIT License 5 votes vote down vote up
private void updateRom(int offset,
        JSpinner sr1,
        JSpinner sg1,
        JSpinner sb1,
        JSpinner sr2,
        JSpinner sg2,
        JSpinner sb2) {
    int r1 = (Integer)sr1.getValue();
    int g1 = (Integer)sg1.getValue();
    int b1 = (Integer)sb1.getValue();
    // gggrrrrr 0bbbbbgg
    romImage[offset] = (byte)(r1 | (g1 << 5));
    romImage[offset + 1] = (byte)((g1 >> 3) | (b1 << 2));

    int r2 = (Integer)sr2.getValue();
    int g2 = (Integer)sg2.getValue();
    int b2 = (Integer)sb2.getValue();
    romImage[offset + 6] = (byte)(r2 | (g2 << 5));
    romImage[offset + 7] = (byte)((g2 >> 3) | (b2 << 2));

    // Generating antialiasing colors.
    int rMid = (r1 + r2) / 2;
    int gMid = (g1 + g2) / 2;
    int bMid = (b1 + b2) / 2;
    romImage[offset + 2] = (byte)(rMid | (gMid << 5));
    romImage[offset + 3] = (byte)((gMid >> 3) | (bMid << 2));
    romImage[offset + 4] = romImage[offset + 2];
    romImage[offset + 5] = romImage[offset + 3];
}
 
Example 4
Source File: OptionsPanel.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Apply new values to the integer options.
 */
private void applyInteger() {
  Configuration config = Configuration.getConfiguration();

  for (Entry<ConfigurationValueInteger, Object> entry : integerValues.entrySet()) {
    if ((entry.getValue() != null) && (entry.getKey() != null)) {
      if (entry.getValue() instanceof JSpinner) {
        JSpinner spinner = (JSpinner) entry.getValue();
        Object value = spinner.getValue();
        if (value instanceof Integer) {
          Integer intValue = (Integer) value;
          config.setInt(null, entry.getKey(), intValue.intValue());
        }
      }
      if (entry.getValue() instanceof ButtonGroup) {
        ButtonGroup group = (ButtonGroup) entry.getValue();
        int count = 0;
        Enumeration<AbstractButton> buttons = group.getElements();
        while (buttons.hasMoreElements()) {
          AbstractButton button = buttons.nextElement();
          if (group.isSelected(button.getModel())) {
            config.setInt(null, entry.getKey(), count);
          }
          count++;
        }
      }
    }
  }
}
 
Example 5
Source File: Welcome.java    From btdex with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	if(e.getSource() == useLedgerButton) {

		JSpinner spinner = new JSpinner(new SpinnerNumberModel(0, 0, 128, 1));
		JPanel spinnerPannel = new JPanel(new BorderLayout());
		spinnerPannel.add(new JLabel("<html>" + tr("ledger_account_index_message")), BorderLayout.CENTER);
		spinnerPannel.add(spinner, BorderLayout.PAGE_END);
		int option = JOptionPane.showOptionDialog(this, spinnerPannel, tr("ledger_account_index"),
				JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
		if (option == JOptionPane.CANCEL_OPTION) {
			return;
		}
		int index = (Integer)spinner.getValue();
		setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
			
		LedgerService.getInstance().setCallBack(this, index);
		return;
	}
	if(e.getSource() == recoverBox) {
		if(recoverBox.isSelected()) {
			passphrase.setText("");
			passphrase.setEditable(true);
			passphrase.requestFocus();
		}
		else {
			passphrase.setEditable(false);
			newPass();
		}
		acceptBox.setSelected(recoverBox.isSelected());
		acceptBox.setEnabled(!recoverBox.isSelected());
	}
	if(e.getSource() == calcelButton) {
		ret = 0;
		setVisible(false);
	}
	if(e.getSource() == okButton) {
		String error = null;
		String phrase = passphrase.getText();

		if(!acceptBox.isSelected()) {
			error = tr("welc_write_phrase");
			acceptBox.requestFocus();
		}
		else if(phrase.length()==0) {
			error = tr("welc_phrase_empty");
			passphrase.requestFocus();				
		}
		else if(pin.getPassword() == null || pin.getPassword().length < 4) {
			error = tr("welc_min_pin");
			pin.requestFocus();
		}
		else if(!Arrays.equals(pin.getPassword(), pinCheck.getPassword())) {
			pin.requestFocus();
			error = tr("welc_wrong_pin");
		}

		if(error == null) {
			Globals g = Globals.getInstance();
			
			// no error, so we have a new phrase
			byte[] privKey = Globals.BC.getPrivateKey(phrase);
			byte[] pubKey = Globals.BC.getPublicKey(privKey);
			
			try {
				if(resetPin) {
					if(!Arrays.equals(g.getPubKey(), pubKey)) {
						error = tr("welc_wrong_phrase");
					}
				}

				if(error == null) {
					g.setKeys(pubKey, privKey, pin.getPassword());
					g.saveConfs();
				}
			} catch (Exception e1) {
				error = e1.getMessage();
			}
		}
		
		if(error!=null) {
			Toast.makeText((JFrame) this.getOwner(), error, Toast.Style.ERROR).display(okButton);
		}
		else {
			ret = 1;
			setVisible(false);
		}
	}
}