View Single Post
Join Date: Jun 2008
Posts: 23
Reputation: rude04 is an unknown quantity at this point 
Solved Threads: 0
rude04 rude04 is offline Offline
Newbie Poster

how to add swf file as JButton

 
0
  #1
Jan 12th, 2009
i want to use a JButton with a rollover sound..so created a button with a sound using adobe macromedia flash...
how can i display it in the swf button in jpanel??
here is the button..button.swf


  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import javax.swing.event.*;
  5.  
  6. public class MyPanel extends JPanel {
  7. private JButton jcomp1;
  8.  
  9. public MyPanel() {
  10. //construct components
  11. jcomp1 = new JButton ("button.swf");
  12.  
  13. //adjust size and set layout
  14. setPreferredSize (new Dimension (220, 149));
  15. setLayout (null);
  16.  
  17. //add components
  18. add (jcomp1);
  19.  
  20. //set component bounds (only needed by Absolute Positioning)
  21. jcomp1.setBounds (55, 90, 100, 25);
  22. }
  23.  
  24.  
  25. public static void main (String[] args) {
  26. JFrame frame = new JFrame ("MyPanel");
  27. frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
  28. frame.getContentPane().add (new MyPanel());
  29. frame.pack();
  30. frame.setVisible (true);
  31. }
  32. }
Last edited by rude04; Jan 12th, 2009 at 9:50 am.
Reply With Quote