List of usage examples for javax.swing JSlider JSlider
public JSlider()
From source file:Main.java
public static void main(String[] argv) throws Exception { // Create a horizontal slider that moves left-to-right JSlider slider = new JSlider(); int tickSpacing = 25; slider.setMajorTickSpacing(tickSpacing); }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Create a horizontal slider with min=0, max=100, value=50 JSlider slider = new JSlider(); // Create a horizontal slider with custom min and max; value is set to the middle int minimum = -255; int maximum = 256; slider = new JSlider(minimum, maximum); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JSlider slider = new JSlider(); slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { JSlider slider = (JSlider) evt.getSource(); if (!slider.getValueIsAdjusting()) { int value = slider.getValue(); System.out.println(value); }//from w w w. j a v a2 s. com } }); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JSlider slider = new JSlider(); Dictionary table = slider.getLabelTable(); ImageIcon icon = new ImageIcon("icon.gif"); JLabel label = new JLabel(icon); // Set at desired positions table.put(new Integer(slider.getMinimum()), label); table.put(new Integer(slider.getMaximum()), label); // Force the slider to use the new labels slider.setLabelTable(table);//from ww w. j a va2s.com }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider oneJSlider = new JSlider(); oneJSlider.setValue(27);//from w w w. j a va 2 s. c om int value = oneJSlider.getValue(); System.out.println(value); oneJSlider.setPaintTicks(true); frame.add(oneJSlider, 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);/* w w w . j a v a 2s. 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:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider oneJSlider = new JSlider(); int newValue = 2; int newExtent = 10; int newMin = 0; int newMax = 10; oneJSlider.getModel().setRangeProperties(newValue, newExtent, newMin, newMax, true); int value = oneJSlider.getValue(); System.out.println(value);/*from w w w.ja va 2 s . c om*/ oneJSlider.setPaintTicks(true); frame.add(oneJSlider, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Filled Slider"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider js1 = new JSlider(); js1.putClientProperty("JSlider.isFilled", Boolean.TRUE); JSlider js2 = new JSlider(); js2.putClientProperty("JSlider.isFilled", Boolean.FALSE); frame.getContentPane().add(js1, BorderLayout.NORTH); frame.getContentPane().add(js2, BorderLayout.SOUTH); frame.setSize(300, 200);/*w w w . j a v a 2 s . c o m*/ frame.setVisible(true); }
From source file:BoundedRangeModelInJSlider.java
public static void main(String args[]) { JFrame frame = new JFrame("Tick Slider"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSlider oneJSlider = new JSlider(); System.out.println(oneJSlider.getModel().getMaximum()); frame.add(oneJSlider, BorderLayout.NORTH); frame.setSize(300, 200);/* w ww .j a v a 2 s .co m*/ frame.setVisible(true); }
From source file:ComplexMessageDemo.java
public static void main(String[] a) { Object complexMsg[] = { "Above Message", new ImageIcon("yourFile.gif"), new JButton("Hello"), new JSlider(), new ImageIcon("yourFile.gif"), "Below Message" }; JOptionPane optionPane = new JOptionPane(); optionPane.setMessage(complexMsg);//w w w . java 2 s . c om optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog(null, "Width 100"); dialog.setVisible(true); }