I created a JDialog
which I want to move and resize. My program draws JDialog
on the screen. When the user clicks it, it should stretch to the width of the screen and then gain height. I tried it like this.
for(int i = 150; i <= width; i += 3) {
dialog.setSize(i, 80);
try {
Thread.sleep(0, 1);
} catch(Exception e2) {}
}
for(int i = 80; i <= 200; i++) {
dialog.setSize(width, i);
try {
Thread.sleep(1);
} catch(Exception e3) {}
}
When the code is executed, it will take a while and then the JDialog will be shown stretched immediately. No expanding is shown.
Well, when the user clicks the dialog again, it will reverse the opening animation and close.
for(int i = 200; i >= 80; i--) {
newMsg.setSize(width, i);
try {
Thread.sleep(0, 1);
} catch(Exception e4) {}
}
for(int i = 0; i >= -width; i -= 3) {
newMsg.setLocation(i, 100);
try {
Thread.sleep(0, 1);
} catch(Exception e5) {}
}
This one works correctly. The movement is able to be seen. As far as I understand, these codes are otherwise identical except they are reversed. Why doesn't the opening work as expected but the closing does?