Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个从 0 开始的 JSpinner,当它的值为 0 时,它的向下箭头按钮应该被禁用,所以值不会改变。有谁知道如何禁用 JSpinner 中的按钮?
您可以使用 SpinnerModel。例如,以下行将值限制在 0 和 MAX_VALUE 之间(即,值从下方以零为界)。参数是:value、min、max、step_size。
JSpinner jSpinner = new JSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1));
注意:该按钮实际上并没有禁用,但不会减小值。