Results 1 to 3 of 3
  1. #1
    Emy
    Emy is offline Member
    Join Date
    Oct 2009
    Posts
    4
    Rep Power
    0

    Default Error in Display applets

    Hi everyBody:
    I have a problem in applets i don't know how to fix it:confused::confused:
    when i do applets no one can display and show the contents , make one applet to display images and put images in the same directory with .class files and didn't display anything:eek::eek:

    and make a new applet that play an audio clip
    that have extension .wav and didn't play

    Is that problem in my computer or in the code with that applet:confused::confused:

    in that code prog that display an audio file
    Java Code:
    package audio;
    import java.awt.event.ActionEvent;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import java.awt.event.ActionListener;
    import java.awt.FlowLayout;
    import java.applet.AudioClip;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JApplet;
    
    public class loadAudioAndPlay extends JApplet {
    
    	private AudioClip sound1,sound2,CurrentSound;
    	private JButton playBtn , stopBtn ,loopBtn;
    	private JComboBox soundJCombo;
    	
    	public void init()
    	{
    		setLayout(new FlowLayout());
    		String choics[]={"Welcome","Hi"};
    		
    		soundJCombo=new JComboBox(choics);
    		soundJCombo.addItemListener(
    		
    				new ItemListener() {
    					
    					@Override
    					public void itemStateChanged(ItemEvent e) {
    				CurrentSound.stop();
    				CurrentSound=soundJCombo.getSelectedIndex()==0 ? sound1 : sound2;
    		
    					}
    				}
    		);
    		
    		
    		add(soundJCombo); //add sound JComboBox to applet
    		
    		buttonHandler handler=new buttonHandler();
    		
    		playBtn=new JButton("Play");
    		playBtn.addActionListener(handler);
    		add(playBtn);
    		
    		loopBtn=new JButton("Loop");
    		loopBtn.addActionListener(handler);
    		add(loopBtn);
    		
    		
    		stopBtn=new JButton("Stop");
    		stopBtn.addActionListener(handler);
    		add(stopBtn);
    		
    		
    		
    		sound1=getAudioClip(getCodeBase(), "SMS_Ringtone_13.wav");
    		sound2=getAudioClip(getCodeBase(), "SMS_Ringtone_12.wav");
    		CurrentSound=sound1;
    		
    		
    		
    	}
    
    	
    	public void stop()
    	{
    		CurrentSound.stop();
    	}
    	
    	
    	private class buttonHandler implements ActionListener{
    
    		@Override
    		public void actionPerformed(ActionEvent e) {
    			
    			// TODO Auto-generated method stub
    			
    			if(e.getSource()==playBtn)
    				CurrentSound.play();
    			else if(e.getSource()==stopBtn)
    				CurrentSound.stop();
    			else if(e.getSource()==loopBtn)
    				CurrentSound.loop();
    			
    			
    			
    			
    			
    			
    			
    			
    			
    			
    			
    			
    		}
    		
    		
    		
    		
    	}
    	
    	
    	
    	
    	
    	
    }

  2. #2
    Emy
    Emy is offline Member
    Join Date
    Oct 2009
    Posts
    4
    Rep Power
    0

    Default

    ?????????????????????????

  3. #3
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    7

    Default

    Nothing wrong with the code, should work if you have kept the wav files and applet in the same folder, if not any other problem is occurring in your system.
    Swastik

Similar Threads

  1. Replies: 8
    Last Post: 12-29-2008, 08:12 AM
  2. Replies: 3
    Last Post: 07-06-2008, 01:35 PM
  3. Replies: 0
    Last Post: 06-28-2008, 10:26 PM
  4. applets on mac what´s going on?
    By willemjav in forum Java Applets
    Replies: 6
    Last Post: 04-19-2008, 08:03 PM
  5. Applets and dll
    By peiceonly in forum Java Applets
    Replies: 1
    Last Post: 04-01-2007, 11:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •