Swing/SpinnerEditor のバックアップ差分(No.17)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/SpinnerEditor へ行く。
- 1 (2004-07-20 (火) 02:14:55)
- 2 (2004-07-20 (火) 02:15:02)
- 3 (2004-07-20 (火) 09:37:42)
- 4 (2004-10-08 (金) 06:25:12)
- 5 (2004-11-04 (木) 10:11:23)
- 6 (2005-04-28 (木) 04:33:09)
- 7 (2005-10-07 (金) 14:40:22)
- 8 (2006-02-27 (月) 16:27:58)
- 9 (2007-04-06 (金) 21:43:45)
- 10 (2010-08-17 (火) 17:39:47)
- 11 (2013-02-20 (水) 15:31:32)
- 12 (2013-04-10 (水) 16:10:50)
- 13 (2014-06-04 (水) 21:49:07)
- 14 (2014-10-29 (水) 01:36:41)
- 15 (2015-11-18 (水) 18:21:02)
- 16 (2016-09-14 (水) 18:08:23)
- 17 (2017-10-17 (火) 15:28:43)
- 18 (2019-04-24 (水) 18:50:45)
- 19 (2020-06-24 (水) 17:01:38)
- 20 (2021-12-01 (水) 08:32:43)
- 追加された行はこの色です。
- 削除された行はこの色です。
--- category: swing folder: SpinnerEditor title: JSpinnerを直接入力不可にする tags: [JSpinner] author: aterai pubdate: 2004-07-19 pubdate: 2004-07-19T11:14:52+09:00 description: JSpinnerのエディタを編集不可にして、ボタンでしか値を変更できないようにします。 image: https://lh3.googleusercontent.com/_9Z4BYR88imo/TQTTojxcMLI/AAAAAAAAAkw/BznS8i5Xfp4/s800/SpinnerEditor.png --- * 概要 [#summary] `JSpinner`のエディタを編集不可にして、ボタンでしか値を変更できないようにします。 #download(https://lh3.googleusercontent.com/_9Z4BYR88imo/TQTTojxcMLI/AAAAAAAAAkw/BznS8i5Xfp4/s800/SpinnerEditor.png) * サンプルコード [#sourcecode] #code(link){{ SpinnerNumberModel model = new SpinnerNumberModel(10, 0, 1000, 1); JSpinner spinner = new JSpinner(model); //UIManager.put("FormattedTextField.inactiveBackground", Color.RED); JTextField field = ((JSpinner.NumberEditor) spinner.getEditor()).getTextField(); field.setEditable(false); field.setBackground(UIManager.getColor("FormattedTextField.background")); }} * 解説 [#explanation] 上記のサンプルでは、「直接編集不可」の場合、上下ボタンで値を変更することはできますが、直接キーボードから値を入力することができないように設定しています。 `JSpinner`の編集可・不可を変更するのではなく、`JSpinner`で使用するエディタから取得した`JTextField`の編集可・不可を切り替えています。 //* 参考リンク [#reference] * コメント [#comment] #comment #comment