OSDN Git Service

設定のsave, load処理
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / gui / FileComboBox.java
1 package yukihane.inqubus.gui;
2
3 import java.awt.Dimension;
4 import javax.swing.JComboBox;
5 import javax.swing.JTextField;
6
7 /**
8  * ComboBoxの幅に入りきらない場合はリストを拡張します.
9  * http://www.jroller.com/santhosh/entry/make_jcombobox_popup_wide_enough
10  * @author yuki
11  */
12 class FileComboBox extends JComboBox<String> {
13
14     private static final long serialVersionUID = 1L;
15     private boolean layingOut = false;
16
17     FileComboBox() {
18         super();
19         setEditable(true);
20     }
21
22     JTextField getEditorComponent() {
23         return (JTextField) getEditor().getEditorComponent();
24     }
25
26     @Override
27     public void doLayout() {
28         try {
29             layingOut = true;
30             super.doLayout();
31         } finally {
32             layingOut = false;
33         }
34     }
35
36     @Override
37     public Dimension getSize() {
38         Dimension dim = super.getSize();
39         if (!layingOut) {
40             dim.width = Math.max(dim.width, getPreferredSize().width);
41         }
42         return dim;
43     }
44 }