List of usage examples for javax.swing JSlider setPaintLabels
@BeanProperty(visualUpdate = true, description = "If true labels are painted on the slider.") public void setPaintLabels(boolean b)
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Tick Slider"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider jSliderOne = new JSlider(); jSliderOne.setPaintLabels(true); Hashtable<Integer, JLabel> table = new Hashtable<Integer, JLabel>(); table.put(0, new JLabel(new ImageIcon("yourFile.gif"))); table.put(10, new JLabel("Ten")); table.put(25, new JLabel("Twenty-Five")); table.put(34, new JLabel("Thirty-Four")); table.put(52, new JLabel("Fifty-Two")); table.put(70, new JLabel("Seventy")); table.put(82, new JLabel("Eighty-Two")); jSliderOne.setLabelTable(table);/* w w w.j ava 2 s.c om*/ frame.add(jSliderOne, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame f = new JFrame("JSlider Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider slider = new JSlider(); slider.setMinorTickSpacing(5);//from ww w .j a v a 2 s .co m slider.setMajorTickSpacing(10); slider.setPaintTicks(true); slider.setSnapToTicks(true); slider.setPaintTrack(false); slider.setPaintLabels(true); f.add(slider, BorderLayout.CENTER); f.setSize(300, 100); f.setVisible(true); }
From source file:SampleSliders.java
public static void main(String args[]) { String title = (args.length == 0 ? "Sample Slider" : args[0]); JFrame f = new JFrame(title); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider js1 = new JSlider(); js1.putClientProperty("JSlider.isFilled", Boolean.TRUE); JSlider js2 = new JSlider(); js2.setMajorTickSpacing(25);//from w w w . j a va2 s . c o m js2.setPaintTicks(true); js2.setSnapToTicks(true); JSlider js3 = new JSlider(JSlider.VERTICAL); js3.setPaintTrack(false); js3.setMinorTickSpacing(5); js3.setMajorTickSpacing(10); js3.setPaintTicks(true); js3.setPaintLabels(true); js3.setSnapToTicks(true); JSlider js4 = new JSlider(JSlider.VERTICAL); Hashtable table = new Hashtable(); table.put(new Integer(0), new JLabel(new DiamondIcon(Color.red))); table.put(new Integer(10), new JLabel("Ten")); table.put(new Integer(25), new JLabel("Twenty-Five")); table.put(new Integer(34), new JLabel("Thirty-Four")); table.put(new Integer(52), new JLabel("Fifty-Two")); table.put(new Integer(70), new JLabel("Seventy")); table.put(new Integer(82), new JLabel("Eighty-Two")); table.put(new Integer(100), new JLabel(new DiamondIcon(Color.black))); js4.setLabelTable(table); js4.setPaintLabels(true); js4.setSnapToTicks(true); Container c = f.getContentPane(); c.add(js1, BorderLayout.NORTH); c.add(js2, BorderLayout.SOUTH); c.add(js3, BorderLayout.WEST); c.add(js4, BorderLayout.EAST); f.setSize(300, 200); f.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { String title = (args.length == 0 ? "Sample Slider" : args[0]); JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider js4 = new JSlider(JSlider.VERTICAL); Hashtable<Integer, JLabel> table = new Hashtable<Integer, JLabel>(); table.put(0, new JLabel("O")); table.put(10, new JLabel("Ten")); table.put(25, new JLabel("Twenty-Five")); table.put(34, new JLabel("Thirty-Four")); table.put(52, new JLabel("Fifty-Two")); table.put(70, new JLabel("Seventy")); table.put(82, new JLabel("Eighty-Two")); table.put(100, new JLabel("100")); js4.setLabelTable(table);//from ww w. ja v a2 s.com js4.setPaintLabels(true); js4.setSnapToTicks(true); frame.add(js4, BorderLayout.EAST); frame.setSize(300, 200); frame.setVisible(true); }
From source file:JSliderOnJOptionPane.java
static JSlider getSlider(final JOptionPane optionPane) { JSlider slider = new JSlider(); slider.setMajorTickSpacing(10);//from w ww . ja va 2s. c o m slider.setPaintTicks(true); slider.setPaintLabels(true); ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { JSlider theSlider = (JSlider) changeEvent.getSource(); if (!theSlider.getValueIsAdjusting()) { optionPane.setInputValue(new Integer(theSlider.getValue())); } } }; slider.addChangeListener(changeListener); return slider; }
From source file:Main.java
public static void setupSl(JSlider sl, int minorTickSpacing, int maximum) { sl.setMaximum(maximum);/*ww w .j av a 2s. co m*/ sl.setMinorTickSpacing(minorTickSpacing); sl.setPaintLabels(true); sl.setPaintTicks(true); sl.setValue(0); }
From source file:MessagePopup.java
public static JSlider getSlider(final JOptionPane optionPane) { JSlider slider = new JSlider(); slider.setMajorTickSpacing(10);//from w ww .ja v a 2 s . co m slider.setPaintTicks(true); slider.setPaintLabels(true); ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { JSlider theSlider = (JSlider) changeEvent.getSource(); if (!theSlider.getValueIsAdjusting()) { optionPane.setInputValue(new Integer(theSlider.getValue())); } } }; slider.addChangeListener(changeListener); return slider; }
From source file:Main.java
/** * Creates a JSlider built//from w w w.j av a2s .c om * using a {@link DefaultBoundedRangeModel} and * containing a {@link MouseWheelListener} * and some usual default settings * * @param model * @return the corresponding {@link JSlider} */ public static JSlider createJSlider(final BoundedRangeModel model) { final JSlider slider = new JSlider(model); slider.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { slider.setValue(-e.getWheelRotation() * model.getMaximum() / 100 + model.getValue()); } }); slider.setPaintTicks(true); slider.setPaintLabels(true); // slider.setMajorTickSpacing(model.getMaximum()/2); // slider.setMinorTickSpacing(model.getMaximum()/10); // slider.setSnapToTicks(true); return slider; }
From source file:Main.java
public Main() { setLayout(new BorderLayout()); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 25); slider.setMinorTickSpacing(2);/*w w w. ja v a 2 s .c o m*/ slider.setMajorTickSpacing(10); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setInverted(false); // We'll just use the standard numeric labels for now... slider.setLabelTable(slider.createStandardLabels(10)); add(slider, BorderLayout.CENTER); }
From source file:Main.java
public Main() { setLayout(new BorderLayout()); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 25); slider.setMinorTickSpacing(2);/*www .j a v a 2 s . c o m*/ slider.setMajorTickSpacing(10); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setOrientation(JSlider.VERTICAL); slider.setInverted(true); // We'll just use the standard numeric labels for now... slider.setLabelTable(slider.createStandardLabels(10)); add(slider, BorderLayout.CENTER); }