

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to move the horizontal slider right-to-left in Java?
At first, let us create a horizontal slider −
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 55);
Now, we will set it to move right-to-left using setInverted() −
slider.setInverted(true);
The following is an example to move the horizontal slider right-to-left −
Example
package my; import java.awt.Color; import java.awt.Font; 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.HORIZONTAL, 0, 100, 55); slider.setInverted(true); slider.setMinorTickSpacing(10); slider.setMajorTickSpacing(25); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setBackground(Color.orange); slider.setForeground(Color.white); Font font = new Font("Serif", Font.BOLD, 20); slider.setFont(font); 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 Questions & Answers
- How to create Horizontal Slider in Java?
- How to move the Y-axis ticks from the left side of the plot to the right side in matplotlib?
- Move columns to the right with Bootstrap
- How to handle right-to-left and left-to-right swipe gestures on Android?
- How to handle right-to-left and left-to-right swipe gestures on iOS App?
- How to create a left-right split pane in Java?
- How to create a horizontal slider with custom min, max, and initial value in Java
- How to handle right-to-left and left-to-right swipe gestures on Android using Kotlin?
- CSS3 Left to right Gradient
- How to handle right to left swipe gestures?
- Print a matrix in alternate manner (left to right then right to left) in C++
- How to hide the track on the slider in Java?
- How to display the JList items from top to bottom and left to right in Java?
- How to create a Box to display components from left to right in Java
- How to display text Right-to-Left Using HTML?
Advertisements