List of usage examples for javax.swing JSlider JSlider
public JSlider(int min, int max)
From source file:savant.snp.SNPFinderPlugin.java
private void setupGUI(JPanel panel) { // add a toolbar JToolBar tb = new JToolBar(); tb.setName("SNP Finder Toolbar"); // add an ON/OFF checkbox JLabel lab_on = new JLabel("On/Off: "); JCheckBox cb_on = new JCheckBox(); cb_on.setSelected(isSNPFinderOn);/*from w ww .j a v a 2 s . c o m*/ // what to do when a user clicks the checkbox cb_on.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // switch the SNP finder on/off setIsOn(!isSNPFinderOn); addMessage("Turning SNP finder " + (isSNPFinderOn ? "on" : "off")); } }); // add a Bookmarking ON/OFF checkbox JLabel lab_bm = new JLabel("Add Bookmarks: "); JCheckBox cb_bm = new JCheckBox(); cb_bm.setSelected(addBookmarks); // what to do when a user clicks the checkbox cb_bm.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // switch the SNP finder on/off setBookmarking(!addBookmarks); addMessage("Turning Bookmarking " + (addBookmarks ? "on" : "off")); } }); JLabel lab_sp = new JLabel("Heterozygosity: "); //add snp prior textfield final JTextField snpPriorField = new JTextField(String.valueOf(snpPrior), 4); snpPriorField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { setSNPPrior(Double.valueOf(snpPriorField.getText())); } catch (NumberFormatException ex) { snpPriorField.setText(String.valueOf(snpPrior)); } } }); int tfwidth = 35; int tfheight = 22; snpPriorField.setPreferredSize(new Dimension(tfwidth, tfheight)); snpPriorField.setMaximumSize(new Dimension(tfwidth, tfheight)); snpPriorField.setMinimumSize(new Dimension(tfwidth, tfheight)); // add a sensitivity slider JLabel lab_confidence = new JLabel("Confidence: "); final JSlider sens_slider = new JSlider(0, 50); sens_slider.setValue(confidence); final JLabel lab_confidence_status = new JLabel("" + sens_slider.getValue()); // what to do when a user slides the slider sens_slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { // set the snp finder's sensitivity lab_confidence_status.setText("" + sens_slider.getValue()); setSensitivity(sens_slider.getValue()); } }); // don't report the new setting until the user stops sliding sens_slider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { addMessage("Changed confidence to " + confidence); } }); // add a transparency slider JLabel lab_trans = new JLabel("Transparency: "); final JSlider trans_slider = new JSlider(0, 100); trans_slider.setValue(transparency); final JLabel lab_transparency_status = new JLabel("" + trans_slider.getValue()); // what to do when a user slides the slider trans_slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { // set the snp finder's transparency lab_transparency_status.setText("" + trans_slider.getValue()); setTransparency(trans_slider.getValue()); } }); // don't report the new setting until the user stops sliding trans_slider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { addMessage("Changed transparency to " + transparency); } }); // add the components to the GUI panel.setLayout(new BorderLayout()); tb.add(lab_on); tb.add(cb_on); tb.add(lab_bm); tb.add(cb_bm); tb.add(new JToolBar.Separator()); tb.add(lab_sp); tb.add(snpPriorField); tb.add(new JToolBar.Separator()); tb.add(lab_confidence); tb.add(sens_slider); tb.add(lab_confidence_status); tb.add(new JToolBar.Separator()); tb.add(lab_trans); tb.add(trans_slider); tb.add(lab_transparency_status); panel.add(tb, BorderLayout.NORTH); // add a text area to the GUI info = new JTextArea(); JScrollPane scrollPane = new JScrollPane(info); panel.add(scrollPane, BorderLayout.CENTER); }
From source file:se.llbit.chunky.renderer.ui.Adjuster.java
/** * Create new double value adjuster//from w w w.ja v a 2 s . c o m * @param label * @param tip * @param min * @param max */ public Adjuster(String label, String tip, double min, double max) { this.min = min; this.max = max; lbl = new JLabel(label + ":"); slider = new JSlider(1, 100); slider.setToolTipText(tip); slider.addChangeListener(this); textField = new JTextField(5); textField.addActionListener(this); integerMode = false; }
From source file:se.llbit.chunky.renderer.ui.Adjuster.java
/** * Create new integer value adjuster//from www . ja va 2 s. c o m * @param label * @param tip * @param min * @param max */ public Adjuster(String label, String tip, int min, int max) { this.min = min; this.max = max; lbl = new JLabel(label); slider = new JSlider(min, max); slider.setToolTipText(tip); slider.addChangeListener(this); textField = new JTextField(5); textField.addActionListener(this); integerMode = true; }