Results 1 to 6 of 6
  1. #1
    daverave1212 is offline Member
    Join Date
    Jul 2015
    Posts
    9
    Rep Power
    0

    Default Some confusing applet questions...

    Hi. I'm new to applets (and java in general). I just learned how to make applets today and there is surprisingly little information about them that I could find and understand.

    Here:

    1) I made a simple .html file:

    <html>
    <body>
    <object code="TestApplet.class" width="400" height="400">
    </object>
    </body>
    </html>


    Class:
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;

    public class TestApplet extends Applet
    {
    Button okButton;
    public void init()
    {

    setLayout(null);

    okButton = new Button("A button");
    okButton.setBounds(20,20,100,30);
    add(okButton);
    }
    }


    When I open the .html file, nothing appears, just a selectable 400x400 white screen.
    The applet works if I run the class directly.
    Both TestApplet.class and the .html file are on my desktop.
    Why doesn't it work?

    2) So, if an applet is supposed to be a single class, what do I do if I made some classes in that class? (Say, I made a class TestApplet2 in class TestApplet)
    *3) More specifically, I just went through the gruesome process of learning how to make buttons work and such, and for those I need to create a class in another class that implements whatever (stuff with actionPerformed and such) and makes buttons work. If you can't use multiple classes in an applet, what do you do?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Some confusing applet questions...

    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Some confusing applet questions...

    Applets are already obsolete. Haven't tried it myself, but I believe the modern replacement is to embed a JavaFX GUI in a web page: https://docs.oracle.com/javafx/2/dep...nt_toolkit.htm

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    daverave1212 is offline Member
    Join Date
    Jul 2015
    Posts
    9
    Rep Power
    0

    Default Re: Some confusing applet questions...

    Take a look at the tutorial: Lesson: Java Applets (The Java™ Tutorials > Deployment)
    I did. Or at least I tried. Most link there are broken and redirect to another page.
    Beside that, I checked tons of tutorials on how to deploy an applet to a website and nothing.

    Applets are already obsolete. Haven't tried it myself, but I believe the modern replacement is to embed a JavaFX GUI in a web page: https://docs.oracle.com/javafx/2/dep...nt_toolkit.htm

    db
    I checked it out and consulted tutorials and I don't understand it at all. I'm having problems understanding some concepts in general in java and it took me a long time (at last too much, imo) to learn stuff like listeners and handlers. I'd just be happy to have someone explain like you explain to a retard human being how to put an applet in an html.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Some confusing applet questions...

    how to put an applet in an html.
    See the section labelled:
    Manually Coding Applet Tag, Launching Without JNLP
    in the tutorial:
    Deploying With the Applet Tag (The Java™ Tutorials > Deployment > Java Applets)
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    daverave1212 is offline Member
    Join Date
    Jul 2015
    Posts
    9
    Rep Power
    0

    Default Re: Some confusing applet questions...

    Thanks for the link. For some reason, many link in there redirect me to an oracle page and idk why :\
    Also, I read about Java Deployment Toolkit that it eases the work of Java Script programmers, not Java and it helps the functionality of Java applications in browser somehow?
    If I decide to create a website from a website builder, will I have an option like "Upload Java Class" ?

Similar Threads

  1. confusing name repite
    By willemjav in forum Advanced Java
    Replies: 19
    Last Post: 12-12-2013, 01:51 PM
  2. Confusing Error
    By CODinacup in forum New To Java
    Replies: 1
    Last Post: 10-02-2012, 04:44 AM
  3. Several newbie questions, applet help mostly
    By gymangel812 in forum New To Java
    Replies: 4
    Last Post: 02-16-2010, 02:00 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
  •