List of usage examples for javax.swing JSpinner getValue
public Object getValue()
editor
. From source file:Main.java
public static void main(String[] argv) throws Exception { // Create a number spinner JSpinner spinner = new JSpinner(); // Set its value spinner.setValue(new Integer(100)); System.out.println(spinner.getValue()); }
From source file:Main.java
public IconEditor(JSpinner s) { super((Icon) s.getValue(), CENTER); icon = (Icon) s.getValue();//from ww w .ja va 2 s . co m spinner = s; spinner.addChangeListener(this); }
From source file:Main.java
public void stateChanged(ChangeEvent evt) { JSpinner spinner = (JSpinner) evt.getSource(); // Get the new value Object value = spinner.getValue(); }
From source file:biomine.bmvis2.pipeline.KMedoidsHighlight.java
@Override public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) { Box ret = new Box(BoxLayout.X_AXIS); ret.add(new JLabel("k:")); final JSpinner spin = new JSpinner(new SpinnerNumberModel(3, 1, 1000, 1)); spin.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { setK(((Number) spin.getValue()).intValue()); v.settingsChanged(false);//from w w w . ja v a 2s. com } }); ret.add(spin); final JCheckBox showClustersBox = new JCheckBox("Color clusters"); ret.add(showClustersBox); showClustersBox.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { showClusters = showClustersBox.isSelected(); v.settingsChanged(false); } }); return ret; }
From source file:eremeykin.pete.plotter.PolarPlotterTopComponent.java
private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner1StateChanged // TODO add your handling code here: JSpinner source = (JSpinner) (evt.getSource()); scale = Double.valueOf(source.getValue().toString()); update();//from w ww .j a v a 2 s .com }
From source file:SpinnerTest.java
/** * Adds a row to the main panel./* w w w . j ava 2s .c o m*/ * @param labelText the label of the spinner * @param spinner the sample spinner */ public void addRow(String labelText, final JSpinner spinner) { mainPanel.add(new JLabel(labelText)); mainPanel.add(spinner); final JLabel valueLabel = new JLabel(); mainPanel.add(valueLabel); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Object value = spinner.getValue(); valueLabel.setText(value.toString()); } }); }
From source file:org.pf.midea.SimulationController.java
public SimulationController(ArrayList<PlanCell> _planCells, JSpinner _spinnerHSquareLow, JSpinner _spinnerHSquareHigh, JSpinner _spinnerHSquareStep, JSpinner _spinnerIterations, boolean _dBs, JProgressBar _progressBar, JPanel _chartPanel, JTextArea _textAreaNumeric, boolean _showLineNumbers) { planCells = _planCells.toArray(new PlanCell[_planCells.size()]); hSquareLow = (Double) _spinnerHSquareLow.getValue(); hSquareHigh = (Double) _spinnerHSquareHigh.getValue(); hSquareStep = (Double) _spinnerHSquareStep.getValue(); iterationsCount = (Integer) _spinnerIterations.getValue(); dBs = _dBs;/*w w w . j av a2s .c o m*/ progressBar = _progressBar; chartPanel = _chartPanel; textAreaNumeric = _textAreaNumeric; showLineNumbers = _showLineNumbers; }
From source file:Forms.FrmPrincipal.java
private boolean validaCapas() { for (int i = 0; i < this.pnlCapas.getComponentCount(); i++) { JSpinner sp = (javax.swing.JSpinner) pnlCapas.getComponent(i); if (Integer.parseInt(sp.getValue().toString()) <= 0) { JOptionPane.showMessageDialog(this, "El nmero de neuronas en la capa " + i + " debe ser mayor a cero."); return false; }// w ww. j av a2 s .co m } return true; }
From source file:Forms.FrmPrincipal.java
private void btnEntrenarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEntrenarActionPerformed int[] capas = new int[Integer.parseInt(this.spIntermedias.getValue().toString()) + 2]; if (validaCapas()) { for (int i = 0; i < this.pnlCapas.getComponentCount(); i++) { JSpinner sp = (javax.swing.JSpinner) pnlCapas.getComponent(i); capas[i] = Integer.parseInt(sp.getValue().toString()); }//from w w w. j a va2 s .c om // BackPropagation entrena = new BackPropagation(capas, matrizPatrones, 100,0.5); BackPropagation entrena = new BackPropagation(capas, matrizPatrones, Integer.parseInt(this.spEpocas.getValue().toString()), Double.parseDouble(this.spFactor.getValue().toString())); // TODO add your handling code here: NeuronResult res = entrena.entrenamiento(); mostrar(res, capas); try { FileOutputStream fos = new FileOutputStream("back.bin"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(entrena); oos.close(); System.out.println("Acabe"); } catch (Exception e) { } } }
From source file:io.github.jeremgamer.editor.panels.GeneralSettings.java
public GeneralSettings() { this.setBorder(BorderFactory.createTitledBorder("")); JPanel namePanel = new JPanel(); JLabel nameLabel = new JLabel("Nom :"); namePanel.add(nameLabel);//from www . j a v a 2s. c o m name.setPreferredSize(new Dimension(220, 30)); namePanel.add(name); CaretListener caretUpdateName = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); gs.set("name", text.getText()); } }; name.addCaretListener(caretUpdateName); this.add(namePanel); adress.setEditable(false); CaretListener caretUpdateAdress = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); gs.set("adress", text.getText()); } }; adress.addCaretListener(caretUpdateAdress); JPanel subTypePanel = new JPanel(); JLabel typeLabel = new JLabel("Type :"); subTypePanel.add(typeLabel); type.setPreferredSize(new Dimension(220, 30)); type.addItem("Minecraft classique"); type.addItem("Minecraft personnalis"); if (new File("projects/" + Editor.getProjectName() + "/data.zip").exists()) { type.setSelectedIndex(1); browse.setEnabled(true); browse.setText("Supprimer l'import"); } else { browse.setEnabled(false); } type.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); if (combo.getSelectedIndex() == 1) { browse.setEnabled(true); adress.setEnabled(true); adress.setEditable(true); } else { browse.setEnabled(false); adress.setEnabled(false); adress.setEditable(false); } gs.set("type", combo.getSelectedIndex()); } }); subTypePanel.add(type); JPanel typePanel = new JPanel(); typePanel.setLayout(new BoxLayout(typePanel, BoxLayout.PAGE_AXIS)); typePanel.add(subTypePanel); JPanel browsePanel = new JPanel(); browsePanel.add(browse); JPanel adressPanel = new JPanel(); adressPanel.setLayout(new BoxLayout(adressPanel, BoxLayout.PAGE_AXIS)); JLabel adressLabel = new JLabel("Adresse de tlchargement :"); adressPanel.setPreferredSize(new Dimension(0, 47)); adress.setPreferredSize(new Dimension(0, 30)); adressPanel.add(adressLabel); adressPanel.add(adress); typePanel.add(adressPanel); this.add(typePanel); closeOnStart.setSelected(true); closeOnStart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (closeOnStart.isSelected()) { gs.set("close", true); } else { gs.set("close", false); } } }); this.add(closeOnStart); JPanel look = new JPanel(); look.setBorder(BorderFactory.createTitledBorder("Apparence")); look.setPreferredSize(new Dimension(290, 340)); JPanel colors = new JPanel(); cDark.setSelected(true); bg.add(cLight); bg.add(cDark); colors.add(cLight); colors.add(cDark); cLight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { gs.set("color", 0); } }); cDark.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { gs.set("color", 1); } }); look.add(colors); JPanel checks = new JPanel(); checks.setLayout(new BoxLayout(checks, BoxLayout.PAGE_AXIS)); borders.setSelected(true); borders.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (borders.isSelected()) { gs.set("borders", true); } else { gs.set("borders", false); } } }); resize.setSelected(true); resize.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (resize.isSelected()) { gs.set("resizable", true); } else { gs.set("resizable", false); } } }); alwaysOnTop.setSelected(false); alwaysOnTop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (alwaysOnTop.isSelected()) { gs.set("top", true); } else { gs.set("top", false); } } }); checks.add(borders); checks.add(resize); checks.add(alwaysOnTop); checks.setPreferredSize(new Dimension(270, 60)); JPanel size = new JPanel(); width.setPreferredSize(new Dimension(57, 30)); widthMin.setPreferredSize(new Dimension(57, 30)); widthMax.setPreferredSize(new Dimension(57, 30)); height.setPreferredSize(new Dimension(57, 30)); heightMin.setPreferredSize(new Dimension(57, 30)); heightMax.setPreferredSize(new Dimension(57, 30)); JPanel widthPanel = new JPanel(); widthPanel.setPreferredSize(new Dimension(130, 150)); widthPanel.setBorder(BorderFactory.createTitledBorder("Largeur")); widthPanel.setLayout(new BoxLayout(widthPanel, BoxLayout.PAGE_AXIS)); JPanel widthPanelBase = new JPanel(); widthPanelBase.add(new JLabel("Base :")); widthPanelBase.add(width); JPanel widthPanelMin = new JPanel(); widthPanelMin.add(new JLabel("Min :")); widthPanelMin.add(Box.createRigidArea(new Dimension(5, 1))); widthPanelMin.add(widthMin); JPanel widthPanelMax = new JPanel(); widthPanelMax.add(new JLabel("Max :")); widthPanelMax.add(Box.createRigidArea(new Dimension(3, 1))); widthPanelMax.add(widthMax); widthPanel.add(widthPanelBase); widthPanel.add(widthPanelMin); widthPanel.add(widthPanelMax); JPanel heightPanel = new JPanel(); heightPanel.setPreferredSize(new Dimension(130, 150)); heightPanel.setBorder(BorderFactory.createTitledBorder("Hauteur")); heightPanel.setLayout(new BoxLayout(heightPanel, BoxLayout.PAGE_AXIS)); JPanel heightPanelBase = new JPanel(); heightPanelBase.add(new JLabel("Base :")); heightPanelBase.add(height); JPanel heightPanelMin = new JPanel(); heightPanelMin.add(new JLabel("Min :")); heightPanelMin.add(Box.createRigidArea(new Dimension(5, 1))); heightPanelMin.add(heightMin); JPanel heightPanelMax = new JPanel(); heightPanelMax.add(new JLabel("Max :")); heightPanelMax.add(Box.createRigidArea(new Dimension(3, 1))); heightPanelMax.add(heightMax); heightPanel.add(heightPanelBase); heightPanel.add(heightPanelMin); heightPanel.add(heightPanelMax); size.add(widthPanel); size.add(heightPanel); width.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("width", spinner.getValue()); } }); widthMin.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("widthMin", spinner.getValue()); } }); widthMax.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); ; gs.set("widthMax", spinner.getValue()); } }); height.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("height", spinner.getValue()); } }); heightMin.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); gs.set("heightMin", spinner.getValue()); } }); heightMax.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); ; gs.set("heightMax", spinner.getValue()); } }); look.add(checks); look.add(size); JPanel bottom = new JPanel(); bottom.setLayout(new BoxLayout(bottom, BoxLayout.LINE_AXIS)); JButton music = new JButton("Ajouter de la musique"); music.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new MusicFrame((JFrame) SwingUtilities.windowForComponent(adress), gs); } }); bottom.add(music); JButton icons = new JButton("Icnes"); icons.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new IconFrame((JFrame) SwingUtilities.windowForComponent(adress)); } }); bottom.add(icons); look.add(bottom); this.add(look); load(); }