RSS Forums RSS

how to add swf file as JButton

Please support our Java advertiser: Programming Forums
Reply
Posts: 21
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

  #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 8:50 am.
AddThis Social Bookmark Button
Reply With Quote  
Posts: 1,957
Reputation: masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold 
Solved Threads: 198
masijade's Avatar
masijade masijade is offline Offline
Posting Virtuoso

Re: how to add swf file as JButton

  #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  
Posts: 21
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

  #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  
Posts: 1,957
Reputation: masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold masijade is a splendid one to behold 
Solved Threads: 198
masijade's Avatar
masijade masijade is offline Offline
Posting Virtuoso

Re: how to add swf file as JButton

  #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  
Posts: 3,465
Reputation: peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold peter_budo is a splendid one to behold 
Solved Threads: 412
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

  #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, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote  
Posts: 21
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

  #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  
Posts: 21
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

  #7  
Jan 12th, 2009
what is java and flex?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the Java Forum
Views: 722 | Replies: 6 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:06 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC