Introduction to Java JSlider Component

Introduction to Java JSlider Component


coding-whizz.blogspot.com
Java JSlider class is used to create Slider object that allows the user to set a range of values.Below are some of use JSlider constructors.

 Java JSlider constructors.

  • JSlider()-creates a slider object with values ranging from 0-100.Default value set as 50.
  • JSlider(int orient)-creates a JSlider with either specified VERTICAL or HORIZONTAL orientation.Values range from 0-100, and the default value is 50.
  • JSlider(int min,int max)-creates slider object with specified maximum and minimum values.
  • JSlider(int min,int max,int value)-Slider created by this constructor has specified minimum and maximum value with default value set.
  • JSlider(int orientation,int min,int max,int value)-Slider created by this constructor has specified minimum, and maximum value with default value set plus also its orientation is set.

 Java JSlider Methods

[
void setMinorTickSpacing(int n)  sets the minor tick spacing to the slider.
void setMajorTickSpacing(int n)     sets the major tick spacing to the slider.
 void setPaintTicks(boolean b)  determines whether tick marks are painted.
void setPaintLabels(boolean b) determines whether labels are painted.
 void setPaintTracks(boolean b)     determines whether track is painted.
]

Java JSlider Example

[
/**This program creates a simple JSlider example 
* * @author Eric */
import javax.swing.JSlider;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class JavaJSlider {
    public static void main(String args[])
    {
        JFrame frame=new JFrame("JSlider Example");
        JSlider slider=new JSlider(JSlider.HORIZONTAL,0,100,50);
        slider.setBounds(10, 10, 300, 30);
        JPanel panel=new JPanel();
        panel.add(slider);
        frame.add(panel);
        frame.pack();
        frame.setSize(300,300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);


    }

}
]

Java JSlider Example with painting ticks

[
/**This program creates a simple JSlider example * 
Its also add minor and major paint tickings 
* * @author Eric */
import javax.swing.JSlider;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class JavaJSlider {
    public static void main(String args[])
    {
        JFrame frame=new JFrame("JSlider Example");
        JSlider slider=new JSlider(JSlider.HORIZONTAL,0,100,50);

        slider.setMinorTickSpacing(2);
        slider.setMajorTickSpacing(10);
        slider.setPaintTicks(true);
        slider.setPaintLabels(true);
        JPanel panel=new JPanel();
        panel.add(slider);
        frame.add(panel);
        frame.pack();
        frame.setSize(300,300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);


    }

}
]
Introduction to Java JSlider Component


Related Tutorials:


COMMENTS

Name

android android Apps android emulators antivirus blogger bluestack Break Statement in Java constructors download downloader drivers emulators java java control statements java do-while loop java for loop java infinitive do-while loop java system methods java tutorials Java While Loop java.awt java.swing javalookandfeel javascript JButton JCheckBox JColorChooser JComboBox JDialog JFileChooser JFrame JLayeredPane JList JMenuBar joomla JOptionPane JPanel JPasswordField JPopupMenu JProgressBar JRadioButton JScrollBar JSlider JSpinner JTabbedPane JTable JTextArea JTextField JToolBar mysql php plugins Polymorphism setToolTiptext skype for windows software swing class themes Visual Studio Code WeChat whatsapp wordpress
false
ltr
item
Java Codes: Introduction to Java JSlider Component
Introduction to Java JSlider Component
Introduction to Java JSlider Component
https://2.bp.blogspot.com/-ix62UMAtWFg/WOANELDLlzI/AAAAAAAAHYo/NEGzMlXdzqk5gIcxXvX6atgrIrVfvkn8wCLcB/s1600/java-JSlider-example-min.PNG
https://2.bp.blogspot.com/-ix62UMAtWFg/WOANELDLlzI/AAAAAAAAHYo/NEGzMlXdzqk5gIcxXvX6atgrIrVfvkn8wCLcB/s72-c/java-JSlider-example-min.PNG
Java Codes
http://www.download-all.net/2017/04/introduction-to-java-jslider-component.html
http://www.download-all.net/
http://www.download-all.net/
http://www.download-all.net/2017/04/introduction-to-java-jslider-component.html
true
7826648292785071009
UTF-8
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy