how to add swf file as JButton

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

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 Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: how to add swf file as JButton

 
0
  #2
Jan 12th, 2009
Well, I can at least say that that's nicely formatted. Otherwise .....

Did you have some sort of question you wished to ask?
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
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

Re: how to add swf file as JButton

 
0
  #3
Jan 12th, 2009
yes..i wanted to use a swf as JButton..how do i do that??
sorry i wasn't done yet with the post when you replied..
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: how to add swf file as JButton

 
0
  #4
Jan 12th, 2009
In that manner, you can't. Create an image that you can create an ImageIcon from to set as the button lable (see the API docs for JButton) and create a Sound file and use a MouseListener to play it with the MouseEntered event (See the Swing tutorials).
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,197
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 485
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: how to add swf file as JButton

 
0
  #5
Jan 12th, 2009
You better look into Java and Flex
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
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

Re: how to add swf file as JButton

 
0
  #6
Jan 12th, 2009
.,uhhm..can you give me a sample code??im not really good at these kind of instructions..I'm just new to java prog..the code that i posted was from a software called guigenie,it lets me drag components in the frame and gives the code..
Reply With Quote Quick reply to this message  
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

Re: how to add swf file as JButton

 
0
  #7
Jan 12th, 2009
what is java and flex?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC