X-Git-Url: http://git.sourceforge.jp/view?p=coroid%2Finqubus.git;a=blobdiff_plain;f=frontend%2Fsrc%2Fyukihane%2Finqubus%2Fgui%2FFileComboBox.java;h=993acd8d900f5f3fde3455a250ec1c3098458f03;hp=9df11680ccb230c7d35a72c4195eb1e688c6e9bd;hb=d19f426c19e48cca24e2741de14ecf4a11cd51d9;hpb=3593cc345d31ce3c4fb45665147ca8f43a50b86b diff --git a/frontend/src/yukihane/inqubus/gui/FileComboBox.java b/frontend/src/yukihane/inqubus/gui/FileComboBox.java index 9df1168..993acd8 100644 --- a/frontend/src/yukihane/inqubus/gui/FileComboBox.java +++ b/frontend/src/yukihane/inqubus/gui/FileComboBox.java @@ -1,15 +1,18 @@ package yukihane.inqubus.gui; +import java.awt.Dimension; import javax.swing.JComboBox; import javax.swing.JTextField; /** - * + * ComboBoxの幅に入りきらない場合はリストを拡張します. + * http://www.jroller.com/santhosh/entry/make_jcombobox_popup_wide_enough * @author yuki */ class FileComboBox extends JComboBox { private static final long serialVersionUID = 1L; + private boolean layingOut = false; FileComboBox() { super(); @@ -19,4 +22,23 @@ class FileComboBox extends JComboBox { JTextField getEditorComponent() { return (JTextField) getEditor().getEditorComponent(); } + + @Override + public void doLayout() { + try { + layingOut = true; + super.doLayout(); + } finally { + layingOut = false; + } + } + + @Override + public Dimension getSize() { + Dimension dim = super.getSize(); + if (!layingOut) { + dim.width = Math.max(dim.width, getPreferredSize().width); + } + return dim; + } }