How to make your ComboBox more wider enough
程序员文章站
2022-04-12 13:14:12
...
import javax.swing.*;
import java.awt.*;
import java.util.Vector;
// got this workaround from the following bug:
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4618607
public class WideComboBox extends JComboBox{
public WideComboBox() {
}
public WideComboBox(final Object items[]){
super(items);
}
public WideComboBox(Vector items) {
super(items);
}
public WideComboBox(ComboBoxModel aModel) {
super(aModel);
}
private boolean layingOut = false;
public void doLayout(){
try{
layingOut = true;
super.doLayout();
}finally{
layingOut = false;
}
}
public Dimension getSize(){
Dimension dim = super.getSize();
if(!layingOut)
dim.width = Math.max(dim.width, getPreferredSize().width);
return dim;
}
}
Here is the original source of this article:
[url]http://www.jroller.com/santhosh/entry/make_jcombobox_popup_wide_enough[/url]
上一篇: mybatis 使用foreach标签批量更新数据
下一篇: ps图片怎么添加丁达尔光线效果?