- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
How to create a Number Spinner in Java?
At first, create a SpinnerModel −
SpinnerModel value = new SpinnerNumberModel(50, 0, 75, 1);
Now, set the values −
JSpinner spinner = new JSpinner(value);
The following is an example to create a number spinner −
Example
package my; import javax.swing.*; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame("Spinner Demo"); SpinnerModel value = new SpinnerNumberModel(50, 0, 75, 1); JSpinner spinner = new JSpinner(value); spinner.setBounds(50, 80, 70, 100); frame.add(spinner); frame.setSize(550,300); frame.setLayout(null); frame.setVisible(true); } }
This will produce the following output −
- Related Articles
- How to create a date spinner in Java?
- How to create a List Spinner in Java?
- How to Create a Spinner in JavaFX?
- How to create spinner Programmatically from array in Android?
- Java Program to set a spinner of dates in Java
- How to get Spinner Value in android?
- How to get Spinner value in Kotlin?
- How to Add Spinner Loader in NextJS?
- How can I add items to a spinner in Android?
- How to Create a Bootstrap Spinner and Display on Screen till the data from the API loads ?
- How to create a HashSet in Java?
- How to create a thread in Java
- How to create a complex number in Python?
- How to create a generic array in java?
- How to create a pdf file in Java?

Advertisements