Applet Loading Failed........

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

Join Date: Jun 2008
Posts: 14
Reputation: funtoosh is an unknown quantity at this point 
Solved Threads: 0
funtoosh funtoosh is offline Offline
Newbie Poster

Applet Loading Failed........

 
0
  #1
Jun 3rd, 2008
I'm trying to make a PhotoAlbum using JApplets.I write a Java code for it and then compile to make a .class file and then made a html file in the same directory which have .class file.But while running it on Web -Browser it doesn't load the applet and shows that Applet doesn't loaded.Help me to figure it out.

Here's my Java code------



import java.awt.*;
import java.applet.*;
import java.applet.Applet;
import java.awt.event.*;
import java.awt.image.*;
public class PhotoAlbum extends Applet implements ActionListener
{

Button
previous = new Button("Previous"),
first = new Button("First"),
last = new Button("Last"),
next = new Button("Next");
Canvas
imageCanvas = new Canvas();

final int total = 6;
int i = 0;
Image Pictures[] = new Image[total]; //Picture Array to store pictures.....
@Override
public void init()
{
makeGui();
for (int p=0; p < total; p++)
{
Pictures[p] = getImage(getCodeBase(),"Katrina"+".JPEG"); // Katrina is the folder name of required pics which is also in the same directory having .class file.
prepareImage(Pictures[p], this);
}
}
private void displayImage(int n)
{
Graphics g = imageCanvas.getGraphics();
g.clearRect(10, 10, 700, 700);
g.drawImage(Pictures[n], 30, 10, this);
g.drawString("Image: "+(n+1)+"/"+total, 30, 500);
}
public void drawFirst()
{
displayImage(0);
}
public void drawLast()
{
displayImage(total-1);
}
public void drawPrevious()
{
i = i - 1;
if (i <= -1)
{
i = total-1;
}
displayImage(i);
}
public void drawNext()
{
i = i + 1;
if (i == total)
{
i = 0;
}
displayImage(i);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == previous)
drawPrevious();
else if (e.getSource() == first)
drawFirst();
else if (e.getSource() == last)
drawLast();
else if (e.getSource() == next)
drawNext();
}

@Override
public void paint(Graphics g)
{
drawFirst();
i = 0;
}

private void makeGui() {

setBackground(Color.black);
setForeground(Color.white);
setLayout(new BorderLayout());

Panel p1 = new Panel();

p1.add(previous);
p1.add(first);

p1.add(next);
p1.add(last);

add(BorderLayout.NORTH, p1);
add(BorderLayout.CENTER, imageCanvas);

previous.addActionListener(this);
first.addActionListener(this);
last.addActionListener(this);
next.addActionListener(this);

}
}



Here's my html file for the Applet:----


<html>
<head>
<title>Photo Album</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p align="center">Photo Album Applet</p>
<hr size="1" align="center">
<div align="center">
<applet code="PhotoAlbum.class" width="700" height="700">
<PARAM NAME="IMAGE1" VALUE="Katrina/kat1.JPEG">
<PARAM NAME="IMAGE2" VALUE="Katrina/kat2.JPEG">
<PARAM NAME="IMAGE3" VALUE="Katrina/kat3.JPEG">
<PARAM NAME="IMAGE4" VALUE="Katrina/kat4.JPEG">
<PARAM NAME="IMAGE5" VALUE="Katrina/kat5.JPEG">
</applet>
</div>
</body>
</html>

Plzz look through it.Thanx in advance........
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 14
Reputation: funtoosh is an unknown quantity at this point 
Solved Threads: 0
funtoosh funtoosh is offline Offline
Newbie Poster

Re: Applet Loading Failed........

 
0
  #2
Jun 4th, 2008
Plzz solve my problem.........
@JavaAddict-- look through it,plzzzzz
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,678
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 226
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is online now Online
Posting Virtuoso

Re: Applet Loading Failed........

 
0
  #3
Jun 4th, 2008
My JApplet skills are a little rusty. But this is what I would suggest. Have you tried to run a single applet as an example that just displays a message in the browser?
Take an example from a tutorial and see if it is displayed correctly.
Then remove what you don't need and try to display everything that you will need except from the pictures.
When you do the above try to add a single picture from a file.
Then try to add the pictures you want.
If you try to do all in once you will not be able to know what is the mistake you have made. But if you try it step by step and somewhere you get an error, you will know at which step is the error.

For example:
don't use: <PARAM NAME="IMAGE1" VALUE="Katrina/kat1.JPEG">
Try at first to hardcode the image in the JApplet class and when you manage to display it, then try to take it from the html.
In that way you will know if the reason why the image is not displayed is the way you get the file name from the html or the code you have in the applet for displaying it.
Last edited by javaAddict; Jun 4th, 2008 at 10:25 am.
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,483
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 515
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Applet Loading Failed........

 
1
  #4
Jun 4th, 2008
Originally Posted by funtoosh View Post
Plzz solve my problem.........
@JavaAddict-- look through it,plzzzzz
"Plzz" is not a word. Please have the consideration to use proper English (at least as much as possible if your English is limited) if you are requesting help. Demanding help in bold text with gibberish words is just plain rude and not likely to get much help.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 14
Reputation: funtoosh is an unknown quantity at this point 
Solved Threads: 0
funtoosh funtoosh is offline Offline
Newbie Poster

Re: Applet Loading Failed........

 
-1
  #5
Jun 4th, 2008
@Ezzaral--- Thanx for your suggestions dude.But I think we are here for not these type of stuffs.... If you can help then you are welcome otherwise please not post these type of stupid threads...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 14
Reputation: funtoosh is an unknown quantity at this point 
Solved Threads: 0
funtoosh funtoosh is offline Offline
Newbie Poster

Re: Applet Loading Failed........

 
0
  #6
Jun 4th, 2008
@JavaAddict-- I have tried to display the Applet in html file.....it works fine... now i will trying to do this one in steps....Thanx for your suggestions.....
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,483
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 515
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Applet Loading Failed........

 
0
  #7
Jun 4th, 2008
Originally Posted by funtoosh View Post
@Ezzaral--- Thanx for your suggestions dude.But I think we are here for not these type of stuffs.... If you can help then you are welcome otherwise please not post these type of stupid threads...
Those suggestions are in accordance with the forum rules that you agree to abide by when you create an account. http://www.daniweb.com/forums/faq.ph..._keep_it_clean
Perhaps you should read them.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC