1) before i hit the start button
3)now i press the start button again(notice that the captured image of the menu bar on the upper left widget):
4)After refreshing:
so i must say that the robot method is not that bad after all!huh?!
;-)
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends JFrame {
JFrame f;
JButton jb;
Dimension t;
public Test(){
f=new JFrame("Flying window");
jb=new JButton("Quit");
//Get the screen size
t=Toolkit.getDefaultToolkit().getScreenSize();
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
//The Fly Out effect
for(int i=t.width/2;i>=0;i-=2)
{
f.setLocation(i,i);
f.repaint();
}
System.exit(0);
}
});
f.getContentPane().add(jb);
f.pack();
f.setSize(100,100);
f.setDefaultCloseOperation(3);
f.setVisible(true);
//The Fly In effect
for(int i=0;i<=t.width/2;i+=2)
{
f.setLocation(i,i);
f.repaint();
}
}
public static void main(String[] s)
{
new Test();
}
}