I am developing a Java Desktop application and designing a GUI using the NetBeans Swing GUI Builder.
I want to use JSpinnerin my application. I dragged it and fell on JPanel. Now I want to set two properties:
JSpinner
JPanel
Firstly, it should display numbers in the range of 1 to 50. Not less than 1 or more than 50. How can I set this range?
Secondly, when I try to get its value spinner.getValue(), it returns Object. Since my spinner data type is Integer, would it be better to disable it Objectin, Integeror is there any other way to get this numeric value?
spinner.getValue()
Object
Integer
From here , a way to do this in NetBeans:
Create a SpinnerNumberModel, this should solve all your problems.
SpinnerNumberModel model = new SpinnerNumberModel(int initialValue, int minValue, int maxValue, int step)
For more information, I recommend reading How to Use Spinners
int myInt = (Integer)mySpinner.getValue();
Java , spinner , SpinnerNumberModel, Ham.
( 1 50). , , . ( ) swing Object ( ).
Swing "" ". Swing.
Source: https://habr.com/ru/post/1743046/More articles:Getting PC value in an ARM assembly - assemblyКак живое редактирование XHTML и CSS в firebug, мы можем провести тестирование javascript без оставления страницы? - javascriptMVC Validator Errors Eliminate Using Time Management for the Controller - validationiPhone SDK Automatically scroll UIWebView to a specific position - iphoneHow to create a controller and action without a model? - ruby-on-railsFailed to link Hello World! - c ++Why does each thread in my application use a different hibernation session? - javausing cfhttp in multiple files taking too much time - coldfusionIsn't that fading away? - c ++Deploying an application with a mannequin / source data - iphoneAll Articles