| | |
how to add swf file as JButton
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2008
Posts: 23
Reputation:
Solved Threads: 0
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
how can i display it in the swf button in jpanel??
here is the button..button.swf
java Syntax (Toggle Plain Text)
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); } }
Last edited by rude04; Jan 12th, 2009 at 9:50 am.
Well, I can at least say that that's nicely formatted. Otherwise .....
Did you have some sort of question you wished to ask?
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
----------------------------------------------
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
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
----------------------------------------------
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
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
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Other Threads in the Java Forum
- Previous Thread: About Pseudorandom Number Generator
- Next Thread: Need to add "java.xml.*" library
| Thread Tools | Search this Thread |
android api applet application applications array arrays automation balls bank binary bluetooth business chat class classes clear client code codesnippet collections component database db defaultmethod development dice dragging draw ebook eclipse error event exception formatingtextintooltipjava fractal game givemetehcodez graphics gui hql html ide image infinite input integer invokingapacheantprogrammatically j2me java javaprojects jni jpanel julia linux list loop looping map method methods mobile mysql netbeans newbie numbers openjavafx oracle parameter php print problem program programming project recursion repositories scanner screen scrollbar server set size sms sort sorting sql sqlserver state storm string sun superclass swing swt text-file threads time tree windows






