Results 1 to 4 of 4
  1. #1
    ocean is offline Senior Member
    Join Date
    Sep 2009
    Location
    Sweden/Borås
    Posts
    107
    Rep Power
    0

    Default image problem when using any browser

    Hello all. Im totally new at this forum. And just as new to Java.

    This is my setup on the server.

    Helloworld.class and helloworldmedia.class in same folder. I have my image in images/world.jpg. I have my sound in audio/audio.wav. this is my code.

    Helloworld.class.
    Java Code:
    import java.applet.*;
    import java.awt.Graphics;
    
    public class helloworld extends Applet {
    	public void init()  {
    	resize(200, 150);
    	}
    	public void paint(Graphics g) {
    	g.drawString("hello world", 50, 100);
    	}
    }
    helloworldmedia.class
    Java Code:
    import java.applet.*;
    import java.awt.*;
    
    public class helloworldmedia extends helloworld {
    	
    	private Image		myImage;
    	private AudioClip	myAudio;
    	
    	public void init() 
    	{
    	super.init();
    	myImage = getImage(getCodeBase(), "images/world.jpg");
    	myAudio = getAudioClip(getCodeBase(), "audio/audio.wav");
    	}
    	public void paint(Graphics g) 
    	{
    	g.drawImage(myImage, 0, 0, this);
    	super.paint(g);
    	}
    	public void start() 
    	{
    	myAudio.loop();
    	}
    	public void stop() 
    	{
    	myAudio.stop();
    	}
    }
    This works great when i use Appletviewer. When i use web browser the string in helloworld are the only thing showing. I have checked so that all the names on folders and path are correct. The audio works great both on viewer and online. And yes one final thing. When i scroll my browser the "hello world" dissapear.

    / ocean

  2. #2
    maxrock's Avatar
    maxrock is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Question

    Im also new here and to java.

    I tried your program with the basic html code that is..

    Java Code:
    <html>
    <body>
    <applet code="helloworldmedia">
    </applet>
    </body>
    </html>

    It works fine for me everywhere.. no problems. I do not know y it is giving you problems. :(

  3. #3
    ocean is offline Senior Member
    Join Date
    Sep 2009
    Location
    Sweden/Borås
    Posts
    107
    Rep Power
    0

    Default

    Must be a browser problem then. thx alot.

  4. #4
    maxrock's Avatar
    maxrock is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

Similar Threads

  1. problem with back button of the browser.
    By shivakumari in forum Java Servlet
    Replies: 2
    Last Post: 03-25-2009, 08:41 AM
  2. Problem with applet, between appletviewer and browser
    By Goodwine in forum Java Applets
    Replies: 0
    Last Post: 11-30-2008, 04:09 AM
  3. Replies: 6
    Last Post: 08-06-2008, 02:41 PM
  4. Problem is getting the data to browser(JSTL)
    By freddieMaize in forum JavaServer Pages (JSP) and JSTL
    Replies: 6
    Last Post: 07-15-2008, 04:04 PM
  5. Problem is getting the data to browser
    By freddieMaize in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-26-2008, 03:49 PM

Posting Permissions

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