"Start: Applet Not Initialized" error

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 3276 Views - Last Post: 20 October 2011 - 05:04 AM Rate Topic: -----

#1 Aalyiah7492  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 19-October 11

"Start: Applet Not Initialized" error

Posted 19 October 2011 - 04:34 AM

Hello All! I have been racking my brain on different ways to get this Applet to work and I have looked for simple errors on my part but I see none that I recgonize! I think I need a second set of eyes on this. Can anyone take a look and tell me if there is something I missed that is causing me to get a "Start: Applet Not Initialized" error from the Applet Viewer?? Please!
I have included the code that I currently have and have some things that I tried commented out right now. Thanks for any insight anyone can give.

[code]
/**
* Class PerformancePaint paint schedule and images in Applet.
*
* @author (Ebony Brewer)
* @version (10162011)
*/

import javax.swing.JApplet;
import java.awt.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.util.Scanner;
import javax.swing.JOptionPane;

public class PerformancePaint extends JApplet
{
PerformanceData performanceData1, performanceData2, performanceData3;
PerformanceData performanceData4, performanceData5, performanceData6;
/**public void init()
{
resize(900,700);
getPerfData();
}
/**
* parseLine method receives a line of text for a performance in the form:
* title#date#time#location#cost, where each piece of data is separated by a hash
* the line is parsed and a response is formatted and returned
*
* @param line - line of text
* @return - response
*/
private static PerformanceData parseLine(String line)
{
JOptionPane.showMessageDialog(null, "entering parseLine");

String title;
String date;
String time;
String location;
double cost;

Scanner dataScan = new Scanner(line);
dataScan.useDelimiter("#");

title = dataScan.nextLine();
date = dataScan.nextLine();
time = dataScan.nextLine();
location = dataScan.nextLine();
cost = dataScan.nextDouble();

PerformanceData perfData = new PerformanceData(title, date , time, location, cost);
return perfData;
}

public void getPerfData()
{
JOptionPane.showMessageDialog(null, "entering getPerfData");
try
{
Scanner scan = new Scanner(new File("schedule.txt"));

performanceData1 = parseLine(scan.nextLine());
performanceData2 = parseLine(scan.nextLine());
performanceData3 = parseLine(scan.nextLine());
performanceData4 = parseLine(scan.nextLine());
performanceData5 = parseLine(scan.nextLine());
performanceData6 = parseLine(scan.nextLine());
}
catch (IOException e)
{
JOptionPane.showMessageDialog(null, "file not opened");//System.out.println("File not found.");
}
}

public void paint(Graphics g)
{
//sets size of Applet Viewer
resize(900,700);
//Recovers Graphics 2D
Graphics2D g2 = (Graphics2D) g;
try
{
//displays right side of curtain at top
Image curtainRight = ImageIO.read(new File("Drama Faces Curtain.jpg"));
g2.drawImage(curtainRight, 0, 0, null);
//displays left side of curtain at top
Image curtainLeft = ImageIO.read(new File("Drama Faces Curtain2.jpg"));
g2.drawImage(curtainLeft, 676, 0, null);
//fills space between curtains with black
g2.fillRect(224, 0, 452, 224);
//changes color to BLUE and fills the rest of the applet window with a blue background
g2.setColor(Color.BLUE);
g2.fillRect(0, 224, 900, 476);
//displays drama faces image in middle of applet
Image dramaFaces = ImageIO.read(new File("Drama Faces1.jpg"));
g2.drawImage(dramaFaces, 350, 230, null);
//displays got drama image on left side of applet
Image gotDrama = ImageIO.read(new File("Got Drama Pic.jpg"));
g2.drawImage(gotDrama, 25, 390, null);
//displays got music image on right side of applet
Image gotMusic = ImageIO.read(new File("Got Music Pic.jpg"));
g2.drawImage(gotMusic, 704, 370, null);
//displays music notes image at mid-bottom of applet
Image musicNotes = ImageIO.read(new File("Music Notes.jpg"));
g2.drawImage(musicNotes, 500, 500, null);
}

catch (IOException e)
{
JOptionPane.showMessageDialog(null, "file not opened");//System.out.println("File not found.");
}
//sets fonts to be used for different play listings and header
Font font1 = new Font("AR HERMANN", Font.BOLD, 30);//hamlet
Font font2 = new Font("AR CHRISTY", Font.BOLD, 30);//loretta
Font font3 = new Font("AR CARTER", Font.BOLD, 30);//oklahoma
Font font4 = new Font("AR BONNIE", Font.BOLD, 30);//cat on a hot
Font font5 = new Font("AR JULIAN", Font.BOLD | Font.ITALIC, 30);//frankenstein
Font font6 = new Font("AR DECODE", Font.BOLD, 30);//romeo
Font font7 = new Font("AR DELANEY", Font.PLAIN, 35);//season pass
Font font8 = new Font("AR BLANCA", Font.BOLD, 50);//csu header

//write CSU performance Schedule at top
Color darkRed = new Color(100, 0, 0);
Color turquoise = new Color(0, 162, 232);
g2.setFont(font8);
g2.setColor(darkRed);
g2.drawString("CSU Performance Schedule", 155, 90);
//writes Fall 2011 under CSU at top
g2.drawString("Fall 2011", 350, 175);
//double total = performanceData1.getCost() + performanceData2.getCost() + performanceData3.getCost() + performanceData4.getCost();
//total += performanceData5.getCost() + performanceData6.getCost() - 12;
//String totalS = String.valueOf(total);
//changes color and font for season pass info and draws season pass info on screen
g2.setFont(font7);
g2.setColor(Color.BLACK);
//g2.drawString("Season Passes are Available for ", 205, 510);

//changes color and font for performanceData1 and draws performance data on screen
g2.setFont(font1);
g2.setColor(Color.ORANGE);
display(g2, performanceData1, 20, 235);

//changes color and font for performanceData2 and draws performance data on screen
g2.setFont(font2);
g2.setColor(Color.GREEN);
JOptionPane.showMessageDialog(null, "got performanceData2");
display(g2, performanceData2, 676, 230);
//changes color and font for performanceData3 and draws performance data on screen
g2.setFont(font3);
g2.setColor(Color.PINK);
display(g2, performanceData3, 155, 370);
//changes color and font for performanceData4 and draws performance data on screen
g2.setFont(font4);
g2.setColor(Color.YELLOW);
display(g2, performanceData4, 350, 370);
//changes color and font for performanceData5 and draws performance data on screen
g2.setFont(font5);
g2.setColor(turquoise);
display(g2, performanceData5, 20, 520);
//changes color and font for performanceData6 and draws performance data on screen
g2.setFont(font6);
g2.setColor(Color.RED);
display(g2, performanceData6, 656, 520);

}

/**
* display method that displays performance data in a certain location
*
* @param g2 the Graphics for this applet
* @param perfData performance data
* @param x x coordinate of location to drawString
* @param y y coordinate of location to drawString
*/
public void display(Graphics2D g2, PerformanceData perfData, int x, int y)
{
String response = perfData.getTitle()+ perfData.getDate() + perfData.getTime() + perfData.getLocation() + perfData.getCost();

g2.drawString(response, x, y);
}
}
[cdoe/]

Is This A Good Question/Topic? 0
  • +

Replies To: "Start: Applet Not Initialized" error

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 04:44 AM

Ahhhhh! Too much code without code tags. Please post your code in code tags. YOu can edit your first post, select all of your code (highlight it) - just the code - then press the [CODE] tool in the editor's tool area.
Was This Post Helpful? 0
  • +
  • -

#3 Aalyiah7492  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 19-October 11

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 06:01 AM

Hello All! I have been racking my brain on different ways to get this Applet to work and I have looked for simple errors on my part but I see none that I recgonize! I think I need a second set of eyes on this. Can anyone take a look and tell me if there is something I missed that is causing me to get a "Start: Applet Not Initialized" error from the Applet Viewer?? Please!
I have included the code that I currently have and have some things that I tried commented out right now. Thanks for any insight anyone can give.


 /**
 * Class PerformancePaint paint schedule and images in Applet.
 * 
* @author (Ebony Brewer) 
* @version (10162011)
 */
 
import javax.swing.JApplet;
 import java.awt.*;
 import java.io.*;
 import javax.imageio.ImageIO;
 import java.util.Scanner;
 import javax.swing.JOptionPane;
 
public class PerformancePaint extends JApplet
 {
 PerformanceData performanceData1, performanceData2, performanceData3;
 PerformanceData performanceData4, performanceData5, performanceData6; 
/**public void init() 
{
 resize(900,700);
 getPerfData();
 }
 /**
 * parseLine method receives a line of text for a performance in the form:
 * title#date#time#location#cost, where each piece of data is separated by a hash
 * the line is parsed and a response is formatted and returned
 * 
* @param line - line of text
 * @return - response
 */
 private static PerformanceData parseLine(String line)
 {
 JOptionPane.showMessageDialog(null, "entering parseLine");
 
String title;
 String date;
 String time;
 String location;
 double cost;
 
Scanner dataScan = new Scanner(line);
 dataScan.useDelimiter("#");
 
title = dataScan.nextLine();
 date = dataScan.nextLine();
 time = dataScan.nextLine();
 location = dataScan.nextLine();
 cost = dataScan.nextDouble();
 
PerformanceData perfData = new PerformanceData(title, date , time, location, cost);
 return perfData;
 } 

public void getPerfData()
 {
 JOptionPane.showMessageDialog(null, "entering getPerfData");
 try
 { 
Scanner scan = new Scanner(new File("schedule.txt")); 

performanceData1 = parseLine(scan.nextLine());
 performanceData2 = parseLine(scan.nextLine());
 performanceData3 = parseLine(scan.nextLine());
 performanceData4 = parseLine(scan.nextLine());
 performanceData5 = parseLine(scan.nextLine());
 performanceData6 = parseLine(scan.nextLine());
 }
 catch (IOException e)
 {
 JOptionPane.showMessageDialog(null, "file not opened");//System.out.println("File not found.");
 }
 }
 
public void paint(Graphics g)
 { 
//sets size of Applet Viewer 
resize(900,700);
 //Recovers Graphics 2D
 Graphics2D g2 = (Graphics2D) g;
 try
 {
 //displays right side of curtain at top
 Image curtainRight = ImageIO.read(new File("Drama Faces Curtain.jpg"));
 g2.drawImage(curtainRight, 0, 0, null);
 //displays left side of curtain at top
 Image curtainLeft = ImageIO.read(new File("Drama Faces Curtain2.jpg"));
 g2.drawImage(curtainLeft, 676, 0, null);
 //fills space between curtains with black
 g2.fillRect(224, 0, 452, 224);
 //changes color to BLUE and fills the rest of the applet window with a blue background
 g2.setColor(Color.BLUE); 
g2.fillRect(0, 224, 900, 476);
 //displays drama faces image in middle of applet 
Image dramaFaces = ImageIO.read(new File("Drama Faces1.jpg"));
 g2.drawImage(dramaFaces, 350, 230, null);
 //displays got drama image on left side of applet
 Image gotDrama = ImageIO.read(new File("Got Drama Pic.jpg"));
 g2.drawImage(gotDrama, 25, 390, null);
 //displays got music image on right side of applet
 Image gotMusic = ImageIO.read(new File("Got Music Pic.jpg"));
 g2.drawImage(gotMusic, 704, 370, null);
 //displays music notes image at mid-bottom of applet
 Image musicNotes = ImageIO.read(new File("Music Notes.jpg"));
 g2.drawImage(musicNotes, 500, 500, null);
 }
 
catch (IOException e)
 {
 JOptionPane.showMessageDialog(null, "file not opened");//System.out.println("File not found.");
 } 
//sets fonts to be used for different play listings and header
 Font font1 = new Font("AR HERMANN", Font.BOLD, 30);//hamlet
 Font font2 = new Font("AR CHRISTY", Font.BOLD, 30);//loretta
 Font font3 = new Font("AR CARTER", Font.BOLD, 30);//oklahoma
 Font font4 = new Font("AR BONNIE", Font.BOLD, 30);//cat on a hot
 Font font5 = new Font("AR JULIAN", Font.BOLD | Font.ITALIC, 30);//frankenstein
 Font font6 = new Font("AR DECODE", Font.BOLD, 30);//romeo
 Font font7 = new Font("AR DELANEY", Font.PLAIN, 35);//season pass
 Font font8 = new Font("AR BLANCA", Font.BOLD, 50);//csu header
 
//write CSU performance Schedule at top
 Color darkRed = new Color(100, 0, 0);
 Color turquoise = new Color(0, 162, 232);
 g2.setFont(font8);
 g2.setColor(darkRed);
 g2.drawString("CSU Performance Schedule", 155, 90);
 //writes Fall 2011 under CSU at top
 g2.drawString("Fall 2011", 350, 175);
 //double total = performanceData1.getCost() + performanceData2.getCost() + performanceData3.getCost() + performanceData4.getCost();
 //total += performanceData5.getCost() + performanceData6.getCost() - 12;
 //String totalS = String.valueOf(total);
 //changes color and font for season pass info and draws season pass info on screen
 g2.setFont(font7);
 g2.setColor(Color.BLACK);
 //g2.drawString("Season Passes are Available for ", 205, 510);
 
//changes color and font for performanceData1 and draws performance data on screen
 g2.setFont(font1);
 g2.setColor(Color.ORANGE);
 display(g2, performanceData1, 20, 235);
 
//changes color and font for performanceData2 and draws performance data on screen
 g2.setFont(font2);
 g2.setColor(Color.GREEN);
 JOptionPane.showMessageDialog(null, "got performanceData2");
 display(g2, performanceData2, 676, 230);
 //changes color and font for performanceData3 and draws performance data on screen
 g2.setFont(font3);
 g2.setColor(Color.PINK);
 display(g2, performanceData3, 155, 370);
 //changes color and font for performanceData4 and draws performance data on screen
 g2.setFont(font4);
 g2.setColor(Color.YELLOW);
 display(g2, performanceData4, 350, 370);
 //changes color and font for performanceData5 and draws performance data on screen
 g2.setFont(font5);
 g2.setColor(turquoise);
 display(g2, performanceData5, 20, 520);
 //changes color and font for performanceData6 and draws performance data on screen
 g2.setFont(font6);
 g2.setColor(Color.RED);
 display(g2, performanceData6, 656, 520);
 
}
 
/**
 * display method that displays performance data in a certain location
 * 
* @param g2 the Graphics for this applet
 * @param perfData performance data
 * @param x x coordinate of location to drawString
 * @param y y coordinate of location to drawString
 */
 public void display(Graphics2D g2, PerformanceData perfData, int x, int y)
 {
 String response = perfData.getTitle()+ perfData.getDate() + perfData.getTime() + perfData.getLocation() + perfData.getCost();
 
g2.drawString(response, x, y);
 }
 }

Was This Post Helpful? 0
  • +
  • -

#4 charpede  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 24
  • Joined: 18-October 11

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 06:23 AM

you don't have an init() method or a main method to run your JApplet, why is that?
Was This Post Helpful? 0
  • +
  • -

#5 Aalyiah7492  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 19-October 11

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 06:31 AM

Its there but I commented it out b/c when I add it the images no longer display (and they were the only things that were actually working in the first place). It also causes the Applet Viewer to give me the error.
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10568
  • View blog
  • Posts: 39,131
  • Joined: 27-December 08

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 06:36 AM

Post your errors when you include the init() method.
Was This Post Helpful? 0
  • +
  • -

#7 charpede  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 24
  • Joined: 18-October 11

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 06:37 AM

well the most common mistake I've seen that is remotely like this one is where the main() method has been deleted or just left out and that is where the class gets initialized, giving the error you see.

I see the init() method commented out but did you have a main() as well
Was This Post Helpful? 0
  • +
  • -

#8 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10568
  • View blog
  • Posts: 39,131
  • Joined: 27-December 08

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 06:38 AM

Applets don't need a main() method. They are designed to be run in an Applet viewer or a web browser.

Also, please avoid duplicate posting.
Was This Post Helpful? 0
  • +
  • -

#9 Aalyiah7492  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 19-October 11

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 06:47 AM

It looks like a duplicate b/c I did not successfully get the code in the tags and could not edit it so I posted it cirrectly and they were combined automatically.
Was This Post Helpful? 0
  • +
  • -

#10 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10568
  • View blog
  • Posts: 39,131
  • Joined: 27-December 08

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 06:48 AM

They were not combined automatically. I merged them manually. If you mess up on the code tags, feel free to report your post so a team member can fix them, or just add an extra post to your current thread with code tags. Thanks! :)
Was This Post Helpful? 0
  • +
  • -

#11 charpede  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 24
  • Joined: 18-October 11

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 06:51 AM

I missed that part of the description, thanks macosxnerd101. I thought he was just trying to run it.


Aalyiah7492 please post the error from the init() method implementation as macosxnerd101 suggested. I'm interested in seeing what it says went wrong.
Was This Post Helpful? 0
  • +
  • -

#12 Aalyiah7492  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 19-October 11

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 01:57 PM

"Start: Applet Not Initialized" error is the only message that the applet viewer gives.
Was This Post Helpful? 0
  • +
  • -

#13 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 08:10 PM

View Postcharpede, on 19 October 2011 - 09:37 AM, said:

well the most common mistake I've seen that is remotely like this one is where the main() method has been deleted or just left out and that is where the class gets initialized, giving the error you see.

I see the init() method commented out but did you have a main() as well

Applet do not need a main() method and as far as the init() one is concerned it is not required neither. The JApplet class has an init() method that does nothing but will be the one called.

You will have to post your class PerformanceData so we can run your code
Was This Post Helpful? 0
  • +
  • -

#14 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 09:00 PM

Your PerformanceData objects are created in perfData()
the only place perfData() is called is in the init() method that you have commented

When init() was not commented it would call perfData()
but these should be next() not nextLine()
		title = dataScan.next();
		date = dataScan.next();
		time = dataScan.next();
		location = dataScan.next();


There is only one line, that will failed, so init() won't finish so your Applet won't be initialized
Was This Post Helpful? 0
  • +
  • -

#15 Aalyiah7492  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 19-October 11

Re: "Start: Applet Not Initialized" error

Posted 19 October 2011 - 09:27 PM

Here is the PerformanceData Class and the file (schedule.txt) that is to be read is attached also.


/**
 * Class PerformanceData sets and retrieves performance information for a program.
 * 
 * @author (Ebony ) 
 * @version (10112011)
 */
public class PerformanceData
{
    // instance variables
    private String title;
    private String date;
    private String time;
    private String location;
    private double cost;

    /**
     * Constructor for objects of class PerformanceData
     * with no parameters
     */
    public PerformanceData()
    {
        // initialize instance variables
        String title;
        String date;
        String time;
        String location;
        double cost;
    }
    
    /**
     * Constructor for objects of class PerformanceData
     */
    public PerformanceData(String title, String date , String time, String location, double cost)
    {
        // initialise instance variables
        this.title = title;
        this.date = date;
        this.time = time;
        this.location = location;
        this.cost = cost;
    }

    /**
     * setTitle - sets the title of a perforamance
     * 
     * @param  newTitle Title of a performance 
     */
    public void setTitle(String newTitle)
    {
        title = newTitle;
    }
    
    /**
     * setDate - sets the title of a perforamance
     * 
     * @param  newTitle Title of a performance 
     */
    public void setDate(String newDate)
    {
        date = newDate;
    }
    
    /**
     * setTime - sets the time of a perforamance
     * 
     * @param  newTime Time of a performance 
     */
    public void setTime(String newTime)
    {
        time = newTime;
    }
    
    /**
     * setLocation - sets the location of a perforamance
     * 
     * @param  newLocation Location of a performance 
     */
    public void setLocation(String newLocation)
    {
        location = newLocation;
    }
    
    /**
     * setCost - sets the cost of a perforamance
     * 
     * @param  newCost Cost of a performance 
     */
    public void setCost(double newCost)
    {
        cost = newCost;
    }
    
    /**
     * getTitle - returns the title of a perforamance
     * 
     * @return   Cost of a performance 
     */
    public String getTitle()
    {
        return title;
    }
    
    /**
     * getDate - returns the date of a perforamance
     * 
     * @return   Date of a performance 
     */
    public String getDate()
    {
        return date;
    }
    
    /**
     * getTime - returns the time of a perforamance
     * 
     * @return   Time of a performance 
     */
    public String getTime()
    {
        return time;
    }
    
    /**
     * getLocation - returns the location of a perforamance
     * 
     * @return   Location of a performance 
     */
    public String getLocation()
    {
        return location;
    }
    
    /**
     * getCost - returns the cost of a perforamance
     * 
     * @return   Cost of a performance 
     */
    public double getCost()
    {
        return cost;
    }
        
    /**
     * to String - returns a description of the instance variable and their values
     * 
     */
    public String toString()
    {
        String response = title + date + time + location + cost;
        return response;
    }
}

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2