当前位置:编程学习 > JAVA >>

求助,重写了JComboBox的BasicComboBoxUI,为什么JComboBox的边框消失了??


望哪位大神指点下,万分感谢啊!!! --------------------编程问答--------------------
class LargerComboBoxUI extends BasicComboBoxUI {
public void installUI(JComponent comboBox) {
        super.installUI(comboBox);
    }

protected ComboPopup createPopup() {
return new LargerComboPopup(comboBox);
}

public class LargerComboPopup extends BasicComboPopup {
public LargerComboPopup(JComboBox comboBox) {
super(comboBox);
}

public void show() {
int selectedIndex = comboBox.getSelectedIndex();
if (selectedIndex == -1) {
list.clearSelection();
} else {
list.setSelectedIndex(selectedIndex);
list.ensureIndexIsVisible(selectedIndex);
}

Insets insets = getInsets();
Dimension listDim = list.getPreferredSize();
boolean hasScrollBar = scroller.getViewport().getViewSize().height != listDim.height;
if (hasScrollBar) {
JScrollBar scrollBar = scroller.getVerticalScrollBar();
listDim.width += scrollBar.getPreferredSize().getWidth();
}

int width = Math.max(listDim.width, comboBox.getWidth()
- (insets.right + insets.left));
int height = getPopupHeightForRowCount(comboBox
.getMaximumRowCount());
Rectangle popupBounds = computePopupBounds(0, comboBox.getHeight(),
width, height);

Dimension scrollSize = popupBounds.getSize();
scroller.setMaximumSize(scrollSize);
scroller.setPreferredSize(scrollSize);
scroller.setMinimumSize(scrollSize);

list.revalidate();
show(comboBox, popupBounds.x, popupBounds.y);
}
}
}


这是重写的源代码 --------------------编程问答-------------------- 居然没人回复
补充:Java ,  Java SE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,