List of usage examples for javax.swing JSpinner getValue
public Object getValue()
editor
. From source file:coreferenceresolver.gui.MarkupGUI.java
private JScrollPane newMarkupPanel(NounPhrase np, ReviewElement reviewElement) { //MODEL/*w w w. jav a 2 s. c o m*/ Element element = new Element(); //Newly added ScrollablePanel markupPanel = new ScrollablePanel(); markupPanel.setLayout(new BoxLayout(markupPanel, BoxLayout.X_AXIS)); markupPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT); JTextArea npContentTxtArea = new JTextArea(); npContentTxtArea.setEditable(false); npContentTxtArea.setText(((MarkupNounPhrase) np).content); markupPanel.add(npContentTxtArea); //REF SpinnerModel refSpinnerModel = new SpinnerNumberModel(np.getChainId(), -1, COLORS.length - 1, 1); JSpinner refSpinner = new JSpinner(refSpinnerModel); refSpinner.setValue(np.getChainId()); refSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { np.setChainId((int) refSpinner.getValue()); try { rePaint(reviewElements.get(np.getReviewId()), np); } catch (BadLocationException ex) { Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex); } } }); element.refSpinner = refSpinner; //TYPE String[] typeValues = { "Object", "Other", "Candidate", "Attribute" }; SpinnerModel typeSpinnerModel = new SpinnerListModel(typeValues); JSpinner typeSpinner = new JSpinner(typeSpinnerModel); typeSpinner.setValue(typeValues[np.getType()]); element.typeSpinner = typeSpinner; //REF + TYPE ScrollablePanel spinners = new ScrollablePanel(); spinners.setLayout(new BoxLayout(spinners, BoxLayout.X_AXIS)); spinners.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT); spinners.add(refSpinner); spinners.add(typeSpinner); markupPanel.add(spinners); reviewElement.addElement(element); JScrollPane scrollMarkupPanel = new JScrollPane(markupPanel); return scrollMarkupPanel; }
From source file:com.alvermont.terraj.stargen.ui.StargenFrame.java
private void lumSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_lumSpinnerStateChanged {//GEN-HEADEREND:event_lumSpinnerStateChanged JSpinner src = (JSpinner) evt.getSource(); this.parameters.setMass((Double) src.getValue()); }
From source file:com.alvermont.terraj.stargen.ui.StargenFrame.java
private void massSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_massSpinnerStateChanged {//GEN-HEADEREND:event_massSpinnerStateChanged JSpinner src = (JSpinner) evt.getSource(); this.parameters.setMass((Double) src.getValue()); }
From source file:com.alvermont.terraj.stargen.ui.StargenFrame.java
private void seedSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_seedSpinnerStateChanged {//GEN-HEADEREND:event_seedSpinnerStateChanged JSpinner src = (JSpinner) evt.getSource(); this.parameters.setSeed(((Number) src.getValue()).longValue()); }
From source file:com.alvermont.terraj.stargen.ui.StargenFrame.java
private void distanceSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_distanceSpinnerStateChanged {//GEN-HEADEREND:event_distanceSpinnerStateChanged JSpinner src = (JSpinner) evt.getSource(); this.parameters.setDistance((Double) src.getValue()); }
From source file:com.alvermont.terraj.stargen.ui.StargenFrame.java
private void declinationSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_declinationSpinnerStateChanged {//GEN-HEADEREND:event_declinationSpinnerStateChanged JSpinner src = (JSpinner) evt.getSource(); this.parameters.setDeclination((Double) src.getValue()); }
From source file:com.alvermont.terraj.stargen.ui.StargenFrame.java
private void ascensionSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_ascensionSpinnerStateChanged {//GEN-HEADEREND:event_ascensionSpinnerStateChanged JSpinner src = (JSpinner) evt.getSource(); this.parameters.setRightAscension((Double) src.getValue()); }
From source file:com.alvermont.terraj.stargen.ui.StargenFrame.java
private void hipSpinnerStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_hipSpinnerStateChanged {//GEN-HEADEREND:event_hipSpinnerStateChanged JSpinner src = (JSpinner) evt.getSource(); this.parameters.setHipparcusNumber((Integer) src.getValue()); }
From source file:io.github.jeremgamer.editor.panels.components.ButtonPanel.java
public ButtonPanel(JFrame frame) { this.frame = frame; this.setSize(new Dimension(395, frame.getHeight() - 27 - 23)); this.setLocation(300, 0); this.setBorder(BorderFactory.createTitledBorder("Edition du bouton")); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); JLabel nameLabel = new JLabel("Nom : "); name.setPreferredSize(new Dimension(this.getWidth() - 285, 30)); name.setEditable(false);/*from w ww.ja v a 2s. c om*/ JPanel namePanel = new JPanel(); namePanel.add(nameLabel); namePanel.add(name); JPanel textPanel = new JPanel(); JPanel nameAndTextPanel = new JPanel(); JLabel textLabel = new JLabel("Texte :"); CaretListener caretUpdateText = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); bs.set("text", text.getText()); preview.setText(text.getText()); preview2.setText(text.getText()); } }; text.addCaretListener(caretUpdateText); text.setPreferredSize(new Dimension(this.getWidth() - 283, 30)); textPanel.add(textLabel); textPanel.add(text); nameAndTextPanel.setLayout(new BoxLayout(nameAndTextPanel, BoxLayout.PAGE_AXIS)); nameAndTextPanel.add(namePanel); nameAndTextPanel.add(textPanel); JPanel policePanel = new JPanel(); JLabel policeLabel = new JLabel("Police : "); police.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) e.getSource(); fontStyle = (String) combo.getSelectedItem(); preview.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); preview2.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); bs.set("police", fontStyle); } }); police.setPreferredSize(new Dimension(105, 30)); GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); for (Font f : fonts) { police.addItem(f.getName()); } police.setSelectedItem("Arial"); policePanel.add(policeLabel); policePanel.add(police); JPanel sizePanel = new JPanel(); size.setPreferredSize(new Dimension(60, 25)); JLabel sizeLabel = new JLabel("Taille : "); sizePanel.add(sizeLabel); sizePanel.add(size); JButton colorButton = new JButton("Couleur"); colorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { colorFrame.setModal(false); JButton finish = new JButton("Terminer"); finish.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { colorFrame.dispose(); } }); colorFrame.setLayout(new BorderLayout()); colorFrame.add(color, BorderLayout.CENTER); colorFrame.add(finish, BorderLayout.SOUTH); colorFrame.pack(); colorFrame.setLocation(SwingUtilities.windowForComponent(imagedButton).getX() + 325, SwingUtilities.windowForComponent(imagedButton).getY() - colorFrame.getHeight() + 40); colorFrame.setVisible(true); } }); sizePanel.add(colorButton); size.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); fontSize = (int) spinner.getValue(); preview.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); preview2.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); bs.set("size", fontSize); } }); JPanel policeAndSize = new JPanel(); policeAndSize.setLayout(new BoxLayout(policeAndSize, BoxLayout.PAGE_AXIS)); policeAndSize.add(policePanel); policeAndSize.add(sizePanel); JPanel top = new JPanel(); top.add(nameAndTextPanel); top.add(policeAndSize); top.setPreferredSize(new Dimension(395, 20)); this.add(top); JPanel images = new JPanel(); images.setBorder(BorderFactory.createTitledBorder("Images")); images.setLayout(new GridLayout(2, 3)); images.setPreferredSize(new Dimension(395, this.getHeight() - 320)); JPanel imaged = new JPanel(); imaged.setLayout(new BorderLayout()); imaged.setBorder(BorderFactory.createTitledBorder("Icne interne")); imagedButton.setSelected(true); imagedButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { bs.set("strings", true); preview.setBorderPainted(true); } else if (ev.getStateChange() == ItemEvent.DESELECTED) { bs.set("strings", false); preview.setBorderPainted(false); } } }); JButton browseInternal = new JButton("Parcourir"); browseInternal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "internal.png"); nameInternal.setText(new File(path).getName()); nameInternal.setPreferredSize(new Dimension(imgBasic.getWidth() - 10, 30)); preview.setIcon(new ImageIcon(path)); preview.repaint(); bs.set("imageInternal", new File(path).getName()); } } }); JPanel northImaged = new JPanel(); northImaged.setLayout(new BorderLayout()); northImaged.add(imagedButton, BorderLayout.NORTH); northImaged.add(browseInternal, BorderLayout.SOUTH); imaged.add(northImaged, BorderLayout.NORTH); imaged.add(nameInternal, BorderLayout.CENTER); JButton removeInternal = null; try { removeInternal = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeInternal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/internal.png"); file.delete(); nameInternal.setText(""); bs.set("imageInternal", ""); preview.setIcon(null); } }); imaged.add(removeInternal, BorderLayout.SOUTH); images.add(imaged); imgBasic.setBorder(BorderFactory.createTitledBorder("Base")); JButton browseBasic = new JButton("Parcourir"); browseBasic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "basic.png"); nameBasic.setText(new File(path).getName()); nameBasic.setPreferredSize(new Dimension(imgBasic.getWidth() - 10, 30)); previewPanel.remove(preview); previewPanel.remove(preview2); previewPanel.add(preview2); color.changePreview(preview2); bs.set("imageBasic", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgBasic.setLayout(new BorderLayout()); imgBasic.add(browseBasic, BorderLayout.NORTH); imgBasic.add(nameBasic, BorderLayout.CENTER); JButton removeBasic = null; try { removeBasic = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeBasic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/basic.png"); file.delete(); nameBasic.setText(""); bs.set("imageBasic", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgBasic.add(removeBasic, BorderLayout.SOUTH); images.add(imgBasic); imgEntered.setBorder(BorderFactory.createTitledBorder("Survol")); JButton browseEntered = new JButton("Parcourir"); browseEntered.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "entered.png"); nameEntered.setText(new File(path).getName()); nameEntered.setPreferredSize(new Dimension(imgEntered.getWidth() - 10, 30)); bs.set("imageEntered", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgEntered.setLayout(new BorderLayout()); imgEntered.add(browseEntered, BorderLayout.NORTH); imgEntered.add(nameEntered, BorderLayout.CENTER); JButton removeEntered = null; try { removeEntered = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeEntered.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/entered.png"); file.delete(); nameEntered.setText(""); bs.set("imageEntered", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgEntered.add(removeEntered, BorderLayout.SOUTH); images.add(imgEntered); imgExited.setBorder(BorderFactory.createTitledBorder("Sortie")); JButton browseExited = new JButton("Parcourir"); browseExited.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "exited.png"); nameExited.setText(new File(path).getName()); nameExited.setPreferredSize(new Dimension(imgExited.getWidth() - 10, 30)); bs.set("imageExited", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgExited.setLayout(new BorderLayout()); imgExited.add(browseExited, BorderLayout.NORTH); imgExited.add(nameExited, BorderLayout.CENTER); JButton removeExited = null; try { removeExited = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeExited.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/exited.png"); file.delete(); nameExited.setText(""); bs.set("imageExited", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgExited.add(removeExited, BorderLayout.SOUTH); images.add(imgExited); imgPressed.setBorder(BorderFactory.createTitledBorder("Clic")); JButton browsePressed = new JButton("Parcourir"); browsePressed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "pressed.png"); namePressed.setText(new File(path).getName()); namePressed.setPreferredSize(new Dimension(imgPressed.getWidth() - 10, 30)); bs.set("imagePressed", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgPressed.setLayout(new BorderLayout()); imgPressed.add(browsePressed, BorderLayout.NORTH); imgPressed.add(namePressed, BorderLayout.CENTER); JButton removePressed = null; try { removePressed = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removePressed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/pressed.png"); file.delete(); namePressed.setText(""); bs.set("imagePressed", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgPressed.add(removePressed, BorderLayout.SOUTH); images.add(imgPressed); imgReleased.setBorder(BorderFactory.createTitledBorder("Relachement")); JButton browseReleased = new JButton("Parcourir"); browseReleased.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "released.png"); nameReleased.setText(new File(path).getName()); nameReleased.setPreferredSize(new Dimension(imgReleased.getWidth() - 10, 30)); bs.set("imageReleased", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgReleased.setLayout(new BorderLayout()); imgReleased.add(browseReleased, BorderLayout.NORTH); imgReleased.add(nameReleased, BorderLayout.CENTER); JButton removeReleased = null; try { removeReleased = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeReleased.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/released.png"); file.delete(); nameReleased.setText(""); bs.set("imageReleased", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgReleased.add(removeReleased, BorderLayout.SOUTH); images.add(imgReleased); this.add(images); JPanel action = new JPanel(); action.setPreferredSize(new Dimension(395, -20)); JLabel labelAction = new JLabel("Action : "); action.add(labelAction); actionList.removeAllItems(); actionList.addItem("Aucune"); for (String s : Actions.getActions()) { actionList.addItem(s); } actionList.setPreferredSize(new Dimension(this.getWidth() - 100, 30)); actionList.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); bs.set("action", combo.getSelectedItem()); } }); action.add(actionList); this.add(action); JScrollPane previewScroll = new JScrollPane(previewPanel); previewScroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); previewPanel.setBorder(BorderFactory.createTitledBorder("Aperu")); previewPanel.add(preview); previewScroll.setPreferredSize(new Dimension(395, 40)); previewScroll.setBorder(null); this.add(previewScroll); }
From source file:configuration.Util.java
public static void buttonEventSpinner(workflow_properties properties, javax.swing.JRadioButton b, javax.swing.JSpinner s) { if (b == null) { properties.put(s.getName(), s.getValue()); } else {//from ww w. j a v a2s .c o m if (b.isSelected() == true) { if (s == null) { properties.put(b.getName(), b.isSelected()); } else { s.setEnabled(true); properties.put(s.getName(), s.getValue()); properties.put(b.getName(), s.getValue()); } } } }