How To Add Flash Animation To Java | Java Programming Tutorial

Monday, August 1, 2011

Now, I want to share about how I can add an animation in java program. Your program will display an animation that make the users of your program won't tired with they works. This also help you focus with multimedia programming. In this trick. I'll give How to Add flash or swf file Animation Into JButton

You Must Prepare a Flash File to display a flash animation in your java. such us (swf). to make your java can display an animation, follow this Source Code :

________________________________________________________

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class MyPanel extends JPanel {
    private JButton jcomp1;

    public MyPanel() {
        //construct components
        jcomp1 = new JButton ("button.swf");

        //adjust size and set layout
        setPreferredSize (new Dimension (220, 149));
        setLayout (null);

        //add components
        add(jcomp1);

        //set component bounds (only needed by Absolute Positioning)
        jcomp1.setBounds (55, 90, 100, 25);
    }

    public static void main (String[] args) {
        JFrame frame = new JFrame ("MyPanel");
        frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add (new MyPanel());
        frame.pack();
        frame.setVisible (true);
    }
}

4 comments:

Nich said...

is the swf file stored in the src folder?

Kent said...

doenst work...

Narayan Singh said...

Thanks!

Unknown said...

go hell man you doing a button his name is "*.swf" thats all

Post a Comment

 
 
 
 
Copyright © Programming Tricks