Swing/LRComboBox のバックアップ差分(No.12)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/LRComboBox へ行く。
- 1 (2005-02-03 (木) 02:04:11)
- 2 (2005-04-28 (木) 04:33:08)
- 3 (2005-09-12 (月) 14:28:49)
- 4 (2006-02-27 (月) 16:11:07)
- 5 (2006-04-08 (土) 20:52:36)
- 6 (2006-12-28 (木) 12:20:40)
- 7 (2007-01-22 (月) 16:18:37)
- 8 (2007-09-16 (日) 00:27:59)
- 9 (2013-03-31 (日) 20:06:27)
- 10 (2015-03-25 (水) 17:00:48)
- 11 (2016-09-27 (火) 17:14:34)
- 12 (2017-11-08 (水) 13:49:35)
- 13 (2018-09-06 (木) 18:12:51)
- 14 (2020-08-30 (日) 20:08:27)
- 15 (2022-03-06 (日) 07:22:26)
- 追加された行はこの色です。
- 削除された行はこの色です。
--- category: swing folder: LRComboBox title: JComboBoxのItemを左右に配置 tags: [JComboBox, Html] author: aterai pubdate: 2005-01-17 pubdate: 2005-01-17T00:09:58+09:00 description: JComboBoxのItemにテキストを左右に分けて配置します。 image: https://lh3.googleusercontent.com/_9Z4BYR88imo/TQTPk2QD9aI/AAAAAAAAAeM/xrl0d1ms74g/s800/LRComboBox.png --- * 概要 [#summary] `JComboBox`の`Item`にテキストを左右に分けて配置します。 #download(https://lh3.googleusercontent.com/_9Z4BYR88imo/TQTPk2QD9aI/AAAAAAAAAeM/xrl0d1ms74g/s800/LRComboBox.png) * サンプルコード [#sourcecode] #code(link){{ class LRItem { private final String leftText; private final String rightText; public LRItem(String strLeft, String strRight) { leftText = strLeft; rightText = strRight; } public String getHtmlText() { return "<html><table width='240'><tr><td align='left'>" + leftText + "</td><td align='right'>" + rightText + "</td></tr></table></html>"; } public String getLeftText() { return leftText; } public String getRightText() { return rightText; } public String toString() { return getHtmlText(); } } }} * 解説 [#explanation] `JComboBox`に`html`の`table`タグを使うことで、`Item`に設定した文字列を左右に振り分けています。 この方法では、`JComboBox`のリストにカラムを簡単に増やすことが出来ます。 上記のサンプルでは、`JComboBox`のサイズ変更に対応していません。 * 参考リンク [#reference] - [[JComboBoxのItemを左右にクリップして配置>Swing/ClippedLRComboBox]] * コメント [#comment] #comment #comment