<分区>
Possible Duplicate:
JDialog allow user to only change width of the dialog
我有一个 JDialog,我希望它的宽度可以调整大小,但高度不能。
这是我当前的代码:
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
setLocation(getLocation().x, getLocation().y + (getHeight() - staticHeight));
setSize(new Dimension(getWidth(), staticHeight));
super.componentResized(e);
}
});
问题是,该代码在调整窗口大小后被调用。使窗口调整大小然后闪烁回来。
我想这样做,当用户试图拖动窗口的高度时它什么都不做。