是否可以禁用 JSpinner 向下箭头按钮?如何?
我有一个从 0 开始的 JSpinner,当其值为 0 时,应禁用其向下箭头按钮,以便该值不会更改。有谁知道如何禁用 JSpinner 中的按钮?
I have a JSpinner which starts at 0 and when its value is 0, its down arrow button should be disabled so the value does not change. Does anyone knows how to disable a button in a JSpinner?
您可以使用 SpinnerModel。例如,下面的行将值限制在 0 和 MAX_VALUE 之间(即,值从下面开始以零为界)。参数为:值、最小值、最大值、步长。
注意:该按钮实际上并没有被禁用,而是不会减少值。
You can use a SpinnerModel. E.g. the following line limits the values between 0 and MAX_VALUE (i.e. values are bounded by zero from below). Arguments are: value, min, max, step_size.
Note: the button is not disabled actually, but does not decrease the value.