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));
注: ボタンは実際には無効になっていませんが、値は減少しません。