Summary
JComboBoxのItemにテキストを左右に分けて配置します。
Screenshot

Advertisement
Source Code Examples
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();
}
}
View in GitHub: Java, KotlinDescription
JComboBoxのItemにtableタグを使用して文字列を左右に振り分けています。
JComboBoxのリストにカラムを追加・削除可能JComboBoxのサイズ変更に未対応
Reference
- JComboBoxのItemを左右にクリップして配置
- セルレンダラーに
JLabelとレイアウトマネージャを適用してカラムを生成
- セルレンダラーに