- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Make the JSlider vertical and move top-to-bottom in Java
To set the JSlider to be vertical, use the VERTICAL constant while creating the slider −
JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 60);
Now, for the inverted slider i.e. moving from top-to-bottom −
slider.setInverted(true);
The following is an example to set the slider vertical and move top-to-bottom −
Example
package my; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.WindowConstants; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame("Frame with Slider"); JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 60); slider.setInverted(true); slider.setMinorTickSpacing(5); slider.setMajorTickSpacing(20); slider.setPaintTicks(true); slider.setPaintLabels(true); JPanel panel = new JPanel(); panel.add(slider); frame.add(panel); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setSize(600, 300); frame.setVisible(true); } }
Output
- Related Articles
- Set the JSlider vertical and move bottom-to-top in Java
- How to change the position of a JSlider to horizontal/vertical programmatically in Java?
- How to move labels from bottom to top without adding "ticks" in Matplotlib?
- How to create a top-bottom split pane in Java?
- How to display the JList items from top to bottom and left to right in Java?
- Java Program to set the extent in JSlider
- CSS3 top to bottom Gradient
- How to specify tab location to make it visible in the bottom with Java?
- Difference Between Top-down and Bottom-up Parsing
- Difference Between Top-down and Bottom-up Approach
- How to change the maximum value of a JSlider in Java?
- How to change the minimum value of a JSlider in Java?
- How to detect the value change of a JSlider in Java?
- How to add a border to the top and bottom of an iOS View?
- How to add a border to the top and bottom of an Android View?

Advertisements