Java Forum / General / October 2005
problems loading applets with html
stewart260@yahoo.com - 20 Oct 2005 01:57 GMT hello, i was wondering if anyone could help me out. its kindof a dumb question, i dont remember how to load applets using html, in fact, i dont remember anyhting with html... if someone could help me out here, that would be great! Spencer
klynn47@comcast.net - 20 Oct 2005 02:15 GMT After you compile the applet's class definition, simply create an HTML document with the following in it.
<applet code=MyApplet width=400 height=400> </applet>
and either load the html file with the appletviewer or a browser.
stewart260@yahoo.com - 20 Oct 2005 02:25 GMT alright... so now whenever i try to load it, i get an error, the screen with an x in the top left corner... um, what could be the problem this time? i compile everything with no errors, my files are all in the same folder... exc. any ideas? Thanks for the help
klynn47@comcast.net - 20 Oct 2005 02:32 GMT Can you post your applet code?
stewart260@yahoo.com - 20 Oct 2005 02:40 GMT <html> <body> <applet code = "brickscreen.class" width = 500 height = 500> </applet>
</body> </html>
klynn47@comcast.net - 20 Oct 2005 02:43 GMT No. I mean the actual applet.
Andrew Thompson - 20 Oct 2005 02:53 GMT > No. I mean the actual applet. Of course.. an applet was meant to live in a web-page, so..
A single web page that includes the applet and *links* to the (short but complete) applet code might be *best*, since everything is in the same place. Also, we can see the console error (or not*) ourselves.
* It might just be the OP's own browser is running an older Java, and the 1.1 compatible code has been compiled for 1.5.
See <http://www.physci.org/codes/sscce.jsp#eg> "Example - Extra Points/Standards on the Internet/ Java Applets" for further details..
stewart260@yahoo.com - 20 Oct 2005 03:06 GMT hey so if it is the 1.1 compatable vod has been compiled for the 1.5, how can i fix this?
Andrew Thompson - 20 Oct 2005 03:11 GMT > hey so if it is the 1.1 compatable vod has been compiled for the 1.5, > how can i fix this? I am not willing to play the '25 guesses' game with applets at the moment. Prepare an SSCCE and post the link - I'll have a look over the applet and code and get back to you.
Roedy Green - 20 Oct 2005 03:53 GMT >hey so if it is the 1.1 compatable vod has been compiled for the 1.5, >how can i fix this? You must post code if you expect help. Your comments border on the unsulting they are so unhelpful. It is hard not to believe you are toying with us.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
stewart260@yahoo.com - 20 Oct 2005 02:58 GMT um, well, its kindof really long... and there are 4 different classes. i have run it without error on another computer, so i am guessing the problem is either with how i was typing it in html, or maybe i dont have java or something on my computer...
Andrew Thompson - 20 Oct 2005 03:09 GMT > um, well, its kindof really long... and there are 4 different classes. Steps (suggested) to solve this problem. 1) prepare an SSCCE 2) ....
stewart260@yahoo.com - 20 Oct 2005 03:12 GMT um, whats that? (should i feel stupid)
stewart260@yahoo.com - 20 Oct 2005 03:21 GMT ok, but wait, if my java creater is 1.1 and my web browser is 1.5 would that create a problem? or would it be the other way around?
stewart260@yahoo.com - 20 Oct 2005 03:30 GMT ok well here is the code... i have a brick class, a brickscreen class, and a dodger class... i realized that in my html file i really called brickmain instead of brickscreen... hope this is what you wanted. Here you go:
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.applet.Applet;
public class brickmain extends JApplet implements KeyListener { private brickscreen displayboard; private JLabel label; private JButton startbutton;
public void init() { displayboard = new brickscreen(); displayboard.setBackground(Color.blue); startbutton = new JButton("Start"); startbutton.addActionListener (new ButtonListener ());
label = new JLabel("Test: "); Container cp = getContentPane(); cp.add(startbutton, BorderLayout.NORTH); cp.add(displayboard, BorderLayout.CENTER); cp.add(label, BorderLayout.SOUTH); addKeyListener(this); }
public void keyPressed(KeyEvent e) { int code = e.getKeyCode();
label.setText(Integer.toString(code));
switch(code) { case KeyEvent.VK_UP: displayboard.moveup(); label.setText("It Worked"); break;
case KeyEvent.VK_RIGHT: displayboard.moveright(); label.setText("It Worked"); break;
case KeyEvent.VK_LEFT: displayboard.moveleft(); label.setText("It Worked"); break;
}
}
public void keyReleased (KeyEvent e) {}
public void keyTyped (KeyEvent e) {}
private class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent event) { requestFocus (); displayboard.start(); } } }
Andrew Thompson - 20 Oct 2005 04:44 GMT > ok well here is the code... ...
> hope this is what you wanted. A lot of the posts that you have made since I posted that link earler, convince me that you *think* you know what I am asking for, but did not read the contents of the web page from start to end.
Please do that, and then you might understand why anything less than a *single* link to the 'broken applet' web-page I described earlier, will be completely ignored by me.
And please drop the "i'm so dumb/toe in the sand" posting style.
Few people would be prepared to continue a conversation with a poster who refuses to put capital letters at the start of sentences, or for the words such as "I"/"I'm" *. I find such text to be quite irritating.
* I am willing to bear with it if English is so difficult for the poster that they do not understand where to put full-stops, but in most instances, that is obviously not the problem.
HalcyonWild - 20 Oct 2005 16:01 GMT > ok well here is the code... i have a brick class, a brickscreen class, > and a dodger class... i realized that in my html file i really called > brickmain instead of brickscreen... > hope this is what you wanted. > Here you go: Try putting the applet class file in the same folder as your html. Also, Put the other classes used by applet class in the same folder. Can you post the exact error too.
Roedy Green - 20 Oct 2005 03:52 GMT >alright... so now whenever i try to load it, i get an error, the screen >with an x in the top left corner... um, what could be the problem this >time? An "error"???. That could be ANYTHING. Look the error up at http://mindprod.com/jgloss/errormessages.html for further help.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Andrew Thompson - 20 Oct 2005 02:18 GMT > hello, i was wondering if anyone could help me out. its kindof a dumb > question, i dont remember how to load applets using html, in fact, i > dont remember anyhting with html... if someone could help me out here, > that would be great! Do you remember Google?
Thomas Fritsch - 20 Oct 2005 02:22 GMT > hello, i was wondering if anyone could help me out. its kindof a dumb > question, i dont remember how to load applets using html, in fact, i > dont remember anyhting with html... if someone could help me out here, > that would be great! > Spencer Well, at least you remember the 2 keywords: html, applet So go to http://www.google.com and enter: html +applet or better, since you look for a tutorial on these, enter: html +applet +tutorial
 Signature "TFritsch$t-online:de".replace(':','.').replace('$','@')
Roedy Green - 20 Oct 2005 03:49 GMT >hello, i was wondering if anyone could help me out. its kindof a dumb >question, i dont remember how to load applets using html, in fact, i >dont remember anyhting with html... if someone could help me out here, >that would be great! >Spencer see http://mindprod.com/jgloss/applet.html http://mindprod.com/jgloss/htmlcheat.html
And just look at the sample html on my website, particularly in http://mindprod.com/applets/amanuenses.html
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|