Swing/NumberEditor のバックアップの現在との差分(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/NumberEditor へ行く。
- 1 (2005-10-31 (月) 11:17:46)
- 2 (2006-01-26 (木) 14:18:23)
- 3 (2006-02-27 (月) 16:17:40)
- 4 (2006-12-28 (木) 12:16:38)
- 5 (2007-09-20 (木) 20:41:11)
- 6 (2013-03-22 (金) 11:45:37)
- 7 (2015-09-30 (水) 19:05:47)
- 8 (2017-04-11 (火) 13:17:25)
- 9 (2018-04-05 (木) 10:30:15)
- 10 (2020-04-03 (金) 17:32:08)
- 11 (2021-10-07 (木) 10:53:37)
- 追加された行はこの色です。
- 削除された行はこの色です。
#navi(../) *JSpinnerの値をパーセントで指定 [#t29c7b07] >編集者:[[Terai Atsuhiro>terai]]~ 作成日:2005-10-31~ 更新日:&lastmod; --- category: swing folder: NumberEditor title: JSpinnerの値をパーセントで指定 tags: [JSpinner] author: aterai pubdate: 2005-10-31T11:17:46+09:00 description: JSpinnerの値をパーセントで指定するように設定します。 image: https://lh4.googleusercontent.com/_9Z4BYR88imo/TQTQecBWSoI/AAAAAAAAAfo/IOSdDmzOIBs/s800/NumberEditor.png --- * 概要 [#summary] `JSpinner`の値をパーセントで指定するように設定します。 #contents **概要 [#v1407fe1] JSpinnerの値をパーセントで指定できるように設定します。 #download(https://lh4.googleusercontent.com/_9Z4BYR88imo/TQTQecBWSoI/AAAAAAAAAfo/IOSdDmzOIBs/s800/NumberEditor.png) http://terai.xrea.jp/swing/numbereditor/screenshot.png * サンプルコード [#sourcecode] #code(link){{ JSpinner spinner = new JSpinner(new SpinnerNumberModel(0, 0, 1, .01)); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner, "0%"); editor.getTextField().setEditable(false); spinner.setEditor(editor); }} **サンプルコード [#k32fce56] JSpinner spinner = new JSpinner(new SpinnerNumberModel(0, 0, 1, 0.01)); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(spinner, "0%"); editor.getTextField().setEditable(false); spinner.setEditor(editor); * 解説 [#explanation] - `JSpinner.NumberEditor`のコンストラクタに`DecimalFormat`オブジェクトのパターンを設定して数値の表示フォーマットを変更 - 数字を表す`0`と`100`倍してパーセントを表す`%`を組み合わせたフォーマットパターンを使用 -[[サンプルを起動>http://terai.xrea.jp/swing/numbereditor/sample.jnlp]] -[[jarファイル>http://terai.xrea.jp/swing/numbereditor/sample.jar]] -[[ソース>http://terai.xrea.jp/swing/numbereditor/src.zip]] **解説 [#af34e284] JSpinner.NumberEditorのコンストラクタに、DecimalFormatオブジェクトのパターンを入力すると数値の解析とフォーマットを行ってくれます。 * 参考リンク [#reference] - [https://docs.oracle.com/javase/jp/8/docs/api/javax/swing/JSpinner.NumberEditor.html JSpinner.NumberEditor (Java Platform SE 8)] 上記のサンプルでは、数字の"0"と、100倍してパーセントを表す"%"のパターンを使用しています。 //**参考リンク **コメント [#f777681c] * コメント [#comment] #comment #comment