I'll be adding it to NYouTube.
Enjoy!
:-)
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();
}
}
5 comments:
Hello,
this is a cool effect, but I'm in doubt, if it will show the same behaviour when I have a really complicated JFrame containing lots of components that have to be redrawn all the time your frame will "fly in or out"...
--Klaus
klaus i have simply changed setLocation() attributes dynamically till the position i want the frame to stop so it will work with the JFrame no matter how complex it may be
Sounds good, I will give it a try...
--Klaus
i am sure u'll like the effect
Meh! Seems no parallelism whatsoever!
Post a Comment