The Artima Developer Community
Sponsored Link

Java Answers Forum
Help with basic Applet

3 replies on 1 page. Most recent reply: Jan 2, 2004 4:01 AM by mausam

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Brandon

Posts: 3
Nickname: brandon
Registered: Dec, 2003

Help with basic Applet Posted: Dec 22, 2003 8:11 AM
Reply to this message Reply
Advertisement
I am trying to run a java applet that is just on my computer. When i open the htm file none of the J-items (ie: buttons and labels) appear and it says in the bottom left: "load *.class not found"

any suggestions on what to do?

Tanks for any help.


Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Applet Problem Posted: Dec 22, 2003 11:16 AM
Reply to this message Reply
There could be many reasons you can get class not found problem. It would be helpful to the perosn who wants to answer your question, if you could mention your directory structure for applet and html files and JDk you are using. I am listing some of the possible thinsg you can try.

1. Applet tag is not suported by IE anymore. If you have installed Java Plugine then it might have asked you that if you wanted to make it available for applet tag. You can verify it on IE -> Tools ->Internet Options -> Advanced Tab.

2. You may want to convert your applet tag into object tag for IE and embed tag for netscape by using HTML converter. It is freely available on java.sun.com.

3. If you are placing your applet class in a package then you may require to set CODEBASE attribute for applet tag.

4. If you are not placing your applet class in a package then try placing your html and class files in the same folder.

5. If none of the above worked for you then post your code, JRE version installed on your machine, folder structures you are using for html and class files. Someone may help you.

Thanks
Kishori

Brandon

Posts: 3
Nickname: brandon
Registered: Dec, 2003

Re: Help with basic Applet Posted: Dec 22, 2003 11:28 AM
Reply to this message Reply
Ok, in IE/tools/internet options/advanced "use JAVA 2v1.4.2_03 for <applet> is checked.

my applet itself:

/Basic Applet to test program
//Calls OhOne

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.event.*;

public class OhOneGUI extends Applet
{
//VARIABLES
OhOne game;

//Starting game objects
Choice gameType;
Choice numPlayers;
Choice difficulty;
JButton start;

//buttons
JButton[] b1 = new JButton[22];
JButton[] b2 = new JButton[22];
JButton[] b3 = new JButton[22];

//labels
JLabel[] plr = new JLabel[22];

JLabel info;

//textFields
JTextField[] plrTxt = new JTextField[22];
JTextField status;

//action listener
MyListener listener = new MyListener();

//APPLET INITIALIZATION
public void init()
{
setLayout(new GridLayout(3,22, 3, 3));

//initialize items
gameType = new Choice();
gameType.add("Select Game");
gameType.add("1");
gameType.add("2");
gameType.add("3");
gameType.add("4");
gameType.add("5");
gameType.add("6");
gameType.add("7");
gameType.add("8");
gameType.add("9");
gameType.add("10");

difficulty = new Choice();
difficulty.add("Select Diff");
difficulty.add("Easy");
difficulty.add("Medium");
difficulty.add("Hard");

numPlayers = new Choice();
numPlayers.add("select Plrs");
for(int i = 1; i < 23; i++)
{
String temp = ""+ i;
numPlayers.add(temp);
}

start = new JButton("Start");
info = new JLabel("Score Average High Low");
status = new JTextField("Game Not Started");
status.setEnabled(false);

b1[20] = new JButton("Bull's Ring");
b1[21] = new JButton("Bull's Eye");

b2[20] = new JButton("");
b2[21] = new JButton("Over");
b3[20] = new JButton("");
b3[21] = new JButton("Reset");

// addButtons();
//}

// public void addButtons()
// {
// removeAll();

add(gameType);
add(difficulty);
add(numPlayers);
add(start);

for(int i = 0; i < 20; i++)
{
int temp = i+1;
String t = "" + temp;

plr = new JLabel(t);
add(plr);

plrTxt = new JTextField();
if(i > game.getPlayers())
plrTxt.setEnabled(false);
add(plrTxt);

b1= new JButton(t);
add(b1);
String t2 = t + " x2";
b2 = new JButton(t2);
add(b2);
String t3 = t + " x3";
b3 = new JButton(t3);
add(b3);
}

add(b1[20]);
add(b2[20]);
add(b3[20]);
add(b1[21]);
add(b2[21]);
add(b3[21]);


}

//ACTION LISTENER
public class MyListener implements ActionListener
{
public void actionPerformed( ActionEvent event ) {}
}
}

- it is not complete yet, i would like to beable to view it so i can also test it.

the file structure is:
c:\darts\OhOne\
and the 2 class files and the htm file are in this directory.

the htm file looks like this:

<HTML>
<HEAD>
</HEAD>
<BODY>
<P>&nbsp;</P>

<APPLET code=OhOneGUI.class height=90% width=90%>
<PARAM NAME="foreground" VALUE="FFFFFF">
<PARAM NAME="background" VALUE="008080">
</APPLET>

</BODY>
</HTML>

hope someone can make sense of this, thanks for any more help.

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Help with basic Applet Posted: Jan 2, 2004 4:01 AM
Reply to this message Reply
How was u able to compile the file itself..

I compiled it by commenting //OhOne game ; as we dont have this class...
we code following errors....for...


//u declare plr as an array Of JLabels
JLabel[] plr = new JLabel[22];

//and then u use code as

plr = new JLabel(t);

//it shud be
plr[i] = new JLabel(t);

//same is the case with

plrTxt = new JTextField(); //its supposed to be arrays....

//first compile ur class boss and c if its getting compiled // or not

Flat View: This topic has 3 replies on 1 page
Topic: \u014F  \301 Previous Topic   Next Topic Topic: native driver for sql server 20000

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use