JExtendedInternalFrame: fix resize behaviour

JDiaAutoScaleFix
Harald Wolff 2018-02-07 10:55:10 +01:00
parent f38b9ce93a
commit 6b36943144
1 changed files with 30 additions and 27 deletions

View File

@ -54,34 +54,37 @@ public class JExtendedInternalFrame extends JInternalFrame
public void componentResized(ComponentEvent e) {
Component dp = getParent();
Dimension dpr = dp.getSize();
Rectangle b = getBounds();
boolean reset = false;
if (b.x < 0) {
reset = true;
b.width += b.x;
b.x = 0;
if(dp != null) {
Dimension dpr = dp.getSize();
Rectangle b = getBounds();
boolean reset = false;
if (b.x < 0) {
reset = true;
b.width += b.x;
b.x = 0;
}
if (b.y < 0) {
reset = true;
b.height += b.y;
b.y = 0;
}
if (b.x + b.width > dpr.width) {
b.width = dpr.width - b.x;
reset = true;
}
if (b.y + b.height > dpr.height){
b.height = dpr.height - b.y;
reset = true;
}
if (reset) {
setBounds(b);
}
}
if (b.y < 0) {
reset = true;
b.height += b.y;
b.y = 0;
}
if (b.x + b.width > dpr.width) {
b.width = dpr.width - b.x;
reset = true;
}
if (b.y + b.height > dpr.height){
b.height = dpr.height - b.y;
reset = true;
}
if (reset) {
setBounds(b);
}
}
});