Hello, when resizing the dialogs in IDEA, it is possible to make them smaller than their minimum size (see attached graphic).
To prevent this, override JDialog's createRootPane() method:
protected JRootPane createRootPane() {
return new QRootPane(this);
}
and create this class:
public class QRootPane extends JRootPane {
private Window window;
public QRootPane(Window window) {
this.window = window;
}
public void reshape(int x, int y, int width, int height) {
Dimension prefSize = getPreferredSize();
if (width < prefSize.width || height < prefSize.height) {
Dimension size = window.getSize();
if (width < prefSize.width) {
size.width = (size.width - width) + prefSize.width;
width = prefSize.width;
}
if (height < prefSize.height) {
size.height = (size.height - height) + prefSize.height;
height = prefSize.height;
}
window.setSize(size);
}
super.reshape(x, y, width, height);
}
}
Best regards,
Thomas Singer
dialogsSmallerThanMinimumSize.png
Description: PNG image
