Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Start: Applet not initiallized

  1. #1
    Member
    Join Date
    Sep 2011
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Start: Applet not initiallized

    Hi,
    Sorry if this is in the wrong place, i didnt know whether to post it under applets or under what wrong with my code...
    So, i have an applet that im trying to run in the browser with this HTML code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <!-- This file automatically generated by BlueJ Java Development  -->
    <!-- Environment.  It is regenerated automatically each time the  -->
    <!-- applet is run.  Any manual changes made to file will be lost -->
    <!-- when the applet is next run inside BlueJ.  Save into a       -->
    <!-- directory outside of the package directory if you want to    -->
    <!-- preserve this file. -->
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>FindAddApplet Applet</title>
        </head>
        <body>
            <h1>FindAddApplet Applet</h1>
            <hr>
            <applet code="FindAddApplet.class" 
                width=500 
                height=500
                codebase="/home/pottsie/TutorProgram"
                archive="file:/usr/share/bluej/bluejcore.jar,file:/usr/share/bluej/junit-4.8.2.jar,file:/home/pottsie/TutorProgram/"
                alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason."
             >
     
                Your browser is ignoring the &lt;APPLET&gt; tag!      
            </applet>
            <hr>
        </body>
    </html>

    However each time i run it i get the error "Start: Applet not initialized"...

    This is the code i am trying to run:
    import java.applet.*;
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.JEditorPane;
    import javax.swing.*;
    public class FindAddApplet extends Applet implements ActionListener
    { 
        private JLabel jcomp1;
        private JButton nextButton;
        private JButton prevButton;
        private JPanel contentPanel;
        //content layout
        private CardLayout cardLayout;
        //jpanel cards
        ClassYearCard classYearCard;
        PeriodCard periodCard;
        NameEmailCard nameEmailCard;
        //labels for cards
        private int currentLabel = 0;
        String classYearLabel = (""+1);
        String periodCardLabel = (""+2);
        String nameEmailLabel = (""+0);
     
        public void init() {
            //construct components
            cardLayout = new CardLayout();
            jcomp1 = new JLabel ("Main Page");
            nextButton = new JButton ("Next >");
            prevButton = new JButton ("< Previous");
            contentPanel = new JPanel ();
            classYearCard = new ClassYearCard();
            periodCard = new PeriodCard();
            nameEmailCard = new NameEmailCard();
     
            //adjust size and set layout
            setPreferredSize (new Dimension (415, 414));
            setLayout (null);
     
            //add components
            add (jcomp1);
            add (nextButton);
            nextButton.addActionListener(this);
            add (prevButton);
            prevButton.addActionListener(this);
            add (contentPanel);
            contentPanel.setLayout(cardLayout); //sets layout of contentPanel
     
            //set content layout
     
            //add stuff to panel
            contentPanel.add(nameEmailCard, nameEmailLabel);
            contentPanel.add(classYearCard, classYearLabel);
            contentPanel.add(periodCard, periodCardLabel);
     
            //set component bounds (only needed by Absolute Positioning)
            jcomp1.setBounds (25, 5, 100, 25);
            nextButton.setBounds (205, 320, 110, 25);
            prevButton.setBounds (85, 320, 110, 25);
            contentPanel.setBounds (15, 30, 300, 285);
        }
     
        public void start() { 
        }
     
        public void actionPerformed(ActionEvent e){
            if (e.getSource() == nextButton){
                currentLabel++;
                cardLayout.show(contentPanel, (""+currentLabel));
            }
            if (e.getSource() == prevButton){
                currentLabel--;
                cardLayout.show(contentPanel, (""+currentLabel));
            }
        }
     
        public void stop() {
        }
     
        public void destroy() {
        }
    }

    The code runs fine in the appletveiwer, so im guessing its the HTML, but i thought it would be better to post both


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,152
    Thanks
    49
    Thanked 2,158 Times in 2,131 Posts

    Default Re: Start: Applet not initiallized

    Are there any error messages in the browser's java console?

Similar Threads

  1. Replies: 0
    Last Post: October 13th, 2011, 07:42 PM
  2. How to start learning JNI
    By 1bun100 in forum Java Native Interface
    Replies: 1
    Last Post: September 20th, 2011, 08:38 AM
  3. Where do i start?
    By cejay in forum Java Theory & Questions
    Replies: 9
    Last Post: September 10th, 2011, 04:21 PM
  4. Start code again?
    By mortalc in forum Loops & Control Statements
    Replies: 12
    Last Post: May 27th, 2010, 07:26 PM
  5. Where to start?
    By tonykasdorf in forum Java Theory & Questions
    Replies: 3
    Last Post: March 4th, 2010, 10:52 PM