Swing/TextFieldMargin のバックアップの現在との差分(No.3)
- バックアップ一覧
- 差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/TextFieldMargin へ行く。
- 1 (2005-06-06 (月) 00:34:45)
- 2 (2005-09-09 (金) 14:31:31)
- 3 (2005-12-16 (金) 02:27:24)
- 4 (2006-02-27 (月) 16:48:36)
- 5 (2006-05-06 (土) 01:52:05)
- 6 (2007-03-13 (火) 00:23:32)
- 7 (2007-10-09 (火) 17:15:14)
- 8 (2007-11-22 (木) 20:23:37)
- 9 (2008-02-02 (土) 22:19:48)
- 10 (2009-10-19 (月) 21:27:30)
- 11 (2009-11-03 (火) 00:09:22)
- 12 (2013-03-28 (木) 18:04:09)
- 13 (2014-11-20 (木) 15:26:14)
- 14 (2015-12-26 (土) 15:56:27)
- 15 (2017-06-14 (水) 18:19:07)
- 16 (2018-06-13 (水) 18:42:52)
- 17 (2020-06-06 (土) 17:17:42)
- 18 (2021-11-18 (木) 11:32:21)
- 追加された行はこの色です。
- 削除された行はこの色です。
#navi(../) *JTextFieldのMarginを設定する [#m4b2abe7] >編集者:[[Terai Atsuhiro>terai]]~ 作成日:2005-06-06~ 更新日:&lastmod; --- category: swing folder: TextFieldMargin title: JTextFieldのMarginを設定する tags: [JTextField, UIManager, Border] author: aterai pubdate: 2005-06-06T00:34:45+09:00 description: JTextFieldにMargin、または二重のBorderを設定して、内余白の変化をテストします。 image: https://lh3.googleusercontent.com/_9Z4BYR88imo/TQTVM2PvsXI/AAAAAAAAAnQ/3wxfaHXrEUk/s800/TextFieldMargin.png --- * 概要 [#summary] `JTextField`に`Margin`、または二重の`Border`を設定して、内余白の変化をテストします。 #contents **概要 [#e2b43068] JTextField内部の余白を設定します。 #download(https://lh3.googleusercontent.com/_9Z4BYR88imo/TQTVM2PvsXI/AAAAAAAAAnQ/3wxfaHXrEUk/s800/TextFieldMargin.png) http://terai.xrea.jp/swing/textfieldmargin/screenshot.png * サンプルコード [#sourcecode] #code(link){{ Insets m = UIManager.getInsets("TextField.margin"); InsetsUIResource iur = new InsetsUIResource(m.top, m.left + 5, m.bottom, m.right); UIManager.put("TextField.margin", iur); **サンプルコード [#h76ab388] Insets m = (Insets) UIManager.get("TextField.margin"); InsetsUIResource iur = new InsetsUIResource(m.top,m.left+5,m.bottom,m.right); UIManager.put("TextField.margin", iur); Insets m = field01.getMargin(); Logger.global.info(m.toString()); Insets margin = new Insets(m.top,m.left+10,m.bottom,m.right); field01.setMargin(margin); Border b1 = BorderFactory.createEmptyBorder(0,20,0,0); Border b2 = BorderFactory.createCompoundBorder(field02.getBorder(), b1); field02.setBorder(b2); Insets m = field01.getMargin(); Insets margin = new Insets(m.top, m.left + 10, m.bottom, m.right); field01.setMargin(margin); -[[サンプルを起動>http://terai.xrea.jp/swing/textfieldmargin/sample.jnlp]] -[[jarファイル>http://terai.xrea.jp/swing/textfieldmargin/sample.jar]] -[[ソース>http://terai.xrea.jp/swing/textfieldmargin/src.zip]] Border b1 = BorderFactory.createEmptyBorder(0, 20, 0, 0); Border b2 = BorderFactory.createCompoundBorder(field02.getBorder(), b1); field02.setBorder(b2); }} **解説 [#q40dbf8e] - 一番上 -- UIManager.put()ですべてのJTextFieldの余白を指定しています。 * 解説 [#explanation] 以下のサンプルでは、それぞれ左側の内余白のサイズのみを変更しています。 - 真ん中 -- 一番上 + setMargin()で余白を指定しています。 // javax.swing.plaf.InsetsUIResource[top=2,left=7,bottom=2,right=2] - 一番下 -- 一番上 + setBorder()で余白を指定しています。 - 上: `UIManager.put()`ですべての`JTextField`の余白を指定 -- `getMargin().left`: `7px` -- `getInsets().left`: `8px` -- `getBorder().getBorderInsets(c).left`: `8px` - 中: 「上(`UIManager.put()`)」と`setMargin()`で余白を指定 -- `getMargin().left`: `17px` -- `getInsets().left`: `18px` -- `getBorder().getBorderInsets(c).left`: `18px` - 下: 「上(`UIManager.put()`)」と`setBorder()`で余白を指定 -- `getMargin().left`: `7px` -- `getInsets().left`: `28px` -- `getBorder().getBorderInsets(c).left`: `28px` 上記のサンプルでは、それぞれ左余白のサイズのみを変更しています。 **参考リンク [#l13dc690] -[[JTextField内にアイコンを追加>Swing/IconTextField]] -[[JComboBoxにアイコンを表示>Swing/IconComboBox]] * 参考リンク [#reference] - [[JTextField内にアイコンを追加>Swing/IconTextField]] - [[JComboBoxにアイコンを表示>Swing/IconComboBox]] **コメント [#z463c6ec] * コメント [#comment] #comment #comment