13 Replies - 925 Views - Last Post: 23 October 2012 - 02:38 PM Rate Topic: -----

#1 Chausse420  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-October 12

Error: Start: Applett not initialized.

Posted 22 October 2012 - 08:54 PM

Ok, I hope I did the code brackets the right way, if not, I am very sorry. I am building a crayon box applet. This is from last year and it worked than, and cannot figure out why i am getting the error in the browser/applet window less than a year later, same program, nothing changed from what I believe. I am using a very simple text editor: Text Pad. I use eclipse for personal use but this for school. Anyways, if anybody can help me on why I am getting this error that would be great. I am very new to HTML so I would imagine it is a problem with the HTML code. Any help would be greatly appreciated!! Thanks in advance!


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

public class CrayonBox
{

   public static void main (String[] args)
   {
      JFrame frame = new JFrame ("CrayonBox");
      frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

      CrayonPanel panel = new CrayonPanel();

      frame.pack();
      frame.setVisible(true);
   }
} 

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

public class CrayonPanel extends JPanel
{
   private Crayon crayon1, crayon2, crayon3, crayon4, crayon5, box;
   private ColorTip colorTip1, colorTip2, colorTip3, colorTip4, colorTip5;
   private DrawWord logo, logo2, logo3, name;

   public CrayonPanel()
   {
      crayon1 = new Crayon (100, 50, Color.red, 15, 100);
      crayon2 = new Crayon (115, 50, Color.green, 15, 100);
      crayon3 = new Crayon (130, 50, Color.cyan, 15, 100);
      crayon4 = new Crayon (145, 50, Color.yellow, 15, 100);
      crayon5 = new Crayon (160, 50, Color.blue, 15, 100);
      box = new Crayon (100, 60, Color.orange, 75, 90);
      logo = new DrawWord ("CRAYONS", 101, 80);
	  logo2 = new DrawWord ("Chris" , 101,130);
	  logo3 = new DrawWord ("Chausse", 101, 142);

	  colorTip1 = new ColorTip (15, Color.red, 99, 40);
	  colorTip2 = new ColorTip (15, Color.green, 114, 40);
	  colorTip3 = new ColorTip (15, Color.cyan, 129, 40);
	  colorTip4 = new ColorTip (15, Color.yellow, 145, 40);
	  colorTip5 = new ColorTip (15, Color.blue, 160, 40);


      setPreferredSize (new Dimension(300, 200));
      setBackground (Color.black);
   }

   public void paintComponent (Graphics page)
   {
      super.paintComponent(page);

      crayon1.draw(page);
      crayon2.draw(page);
      crayon3.draw(page);
      crayon4.draw(page);
      crayon5.draw(page);

      colorTip1.draw(page);
      colorTip2.draw(page);
      colorTip3.draw(page);
      colorTip4.draw(page);
      colorTip5.draw(page);

      box.draw(page);
      logo.draw(page);
  }
}


java.awt.*;

public class ColorTip
{
   private int diameter, x, y;
   private Color color;


   public ColorTip (int size, Color shade, int upperX, int upperY)
   {
      diameter = size;
      color = shade;
      x = upperX;
      y = upperY;
   }


   public void draw (Graphics page)
   {
      page.setColor (color);
      page.fillOval (x, y, diameter, diameter);
   }


   public void setDiameter (int size)
   {
      diameter = size;
   }


   public void setColor (Color shade)
   {
      color = shade;
   }


   public void setX (int upperX)
   {
      x = upperX;
   }


   public void setY (int upperY)
   {
      y = upperY;
   }


   public int getDiameter ()
   {
      return diameter;
   }


   public Color getColor ()
   {
      return color;
   }


   public int getX ()
   {
      return x;
   }


   public int getY ()
   {
      return y;
   }
}



 
import java.awt.*;

public class DrawWord
{
   private int xCord, yCord;
   private String name;

   public DrawWord (String tempName, int startX, int startY)
   {
      tempName = name;
      xCord = startX;
      yCord = startY;
   }

   public void draw (Graphics page)
   {
      Font Default = new Font ("Serif", Font.BOLD, 15);
      page.setFont(Default);
      page.setColor(Color.black);
      page.drawString ("CRAYONS", xCord, yCord);
      page.drawString ("Chris", xCord, yCord+50);
      page.drawString ("Chausse", xCord, yCord+62);
   }



}



import java.awt.*;

public class Crayon
{
   private int width, height, x, y;
   private Color color;


   public Crayon (int upperX, int upperY, Color shade, int sizeW, int sizeH)
   {
      width = sizeW;
      height = sizeH;
      color = shade;
      x = upperX;
      y = upperY;
   }


   public void draw (Graphics page)
   {
      page.setColor (color);
      page.fillRect (x, y, width, height);
   }


   public void setWidth (int sizeW)
   {
      width = sizeW;
   }


   public void setHeight (int sizeH)
   {
      height = sizeH;
   }



   public void setColor (Color shade)
   {
      color = shade;
   }


   public void setX (int upperX)
   {
      x = upperX;
   }


   public void setY (int upperY)
   {
      y = upperY;
   }


   public int getWidth ()
   {
      return width;
   }


      public int getHeight ()
      {
         return height;
   }


   public Color getColor ()
   {
      return color;
   }


   public int getX ()
   {
      return x;
   }


   public int getY ()
   {
      return y;
   }
}

 



<!-- CrayonBox.html --->

<HTML>
<HEAD>
<TITLE> The Snowman Applet </TITLE>
</HEAD>

<BODY>

<H3>The Snowman applet: </H3>

<APPLET CODE = "CrayonBox.class" WIDTH=300 HEIGHT=200>

</APPLET>
</BODY>
</HTML>





Is This A Good Question/Topic? 0
  • +

Replies To: Error: Start: Applett not initialized.

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 12:07 AM

I don't think it was an Applet last year. You need to review the basics of making Applets.
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

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

Reputation: 8346
  • View blog
  • Posts: 31,904
  • Joined: 06-March 08

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 09:23 AM

You haven't post any Applet code... this application never been an Applet
Was This Post Helpful? 0
  • +
  • -

#4 Chausse420  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-October 12

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 11:08 AM

View Postpbl, on 23 October 2012 - 09:23 AM, said:

You haven't post any Applet code... this application never been an Applet



It's a jpanel I believe. Sorry, not a japplet. Beginner programmer here, sorry for using wrong terms.
Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

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

Reputation: 8346
  • View blog
  • Posts: 31,904
  • Joined: 06-March 08

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 11:17 AM

If it is a JPanel it has to go in an Applet or in a JFrame
An Applet can be called by an HTML page, an Application can't and your code is an Application
so:
- or you get ride of your useless .HTML
- or you convert CrayonBox into an Applet so it can be invoked by a .HTML with the Applet tag
Was This Post Helpful? 0
  • +
  • -

#6 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 11:30 AM

So if you run CrayonBox as a Java application, all should be well. I haven't tried it, but it looks okay, and that's probably what you did last year when everything went well. If you have to modify CrayonBox to be in a web page (an .HTML page), then you need to modify your code to be an Applet, JApplet preferred. That can be done fairly easily, and in fact, the same code can be BOTH a normal Java Application or a JApplet. Review the link I sent you in my first post to see how to change the code you have to be an Applet. Come back when/if you need help.
Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

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

Reputation: 8346
  • View blog
  • Posts: 31,904
  • Joined: 06-March 08

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 11:35 AM

http://www.dreaminco...snippet4467.htm
Was This Post Helpful? 0
  • +
  • -

#8 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2831
  • View blog
  • Posts: 11,986
  • Joined: 20-September 08

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 12:18 PM

Quote

Error: Start: Applett not initialized.

Presumably it IS now an applet if that's the error message..?
http://technojeeves....-applet-console

This post has been edited by g00se: 23 October 2012 - 12:19 PM
Reason for edit:: link

Was This Post Helpful? 0
  • +
  • -

#9 Chausse420  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-October 12

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 01:33 PM

View PostGregBrannon, on 23 October 2012 - 11:30 AM, said:

So if you run CrayonBox as a Java application, all should be well. I haven't tried it, but it looks okay, and that's probably what you did last year when everything went well. If you have to modify CrayonBox to be in a web page (an .HTML page), then you need to modify your code to be an Applet, JApplet preferred. That can be done fairly easily, and in fact, the same code can be BOTH a normal Java Application or a JApplet. Review the link I sent you in my first post to see how to change the code you have to be an Applet. Come back when/if you need help.



When I run it as an application from the main method, it comes up with a very small box but nothing in it. With running it with the HTML, I reviewed the link and alot of it is hard for me to understand because I am a beginner programmer. I'm not asking for you to tell me exactly what to do/do homework for me, I'm just asking for an easier way for me to understand so that it can be executed as either JApplet or Application. I just dont understand why it wont execute because nothing has changed from last year. Thanks again for all your guys' help!! Its very much appreciated!!!

I am trying to invoke it to run with the HTML, but it wont run. Is there anything wrong with the HTML code, or am I just running it the wrong way?

If you look at the code with the main method, it looks as tho its made to be run as an application. But still wont run properly, the frame comes up extremely small and there is nothing in it.
Was This Post Helpful? 0
  • +
  • -

#10 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 01:44 PM

Let's getting it running first as an application as you remember it from last year.

For some reason, you're not adding the panel to the frame. Try changing your main method, adding the statement,

frame.add( panel );

before the frame.pack(); statement.

Does that look familiar?
Was This Post Helpful? 0
  • +
  • -

#11 Chausse420  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-October 12

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 01:47 PM

OK, so here is what I did. All I did was import it into Eclipse and ran it as an application and it worked fine. But for some reason it wont run in TextPad. Have no idea why. If anybody can by chance answer that question, that would be absolutely awesome!! But than again, TextPad is a P.O.S. Thanks again for all your guys' help!!!
Was This Post Helpful? 0
  • +
  • -

#12 Chausse420  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-October 12

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 02:21 PM

View PostGregBrannon, on 23 October 2012 - 01:44 PM, said:

Let's getting it running first as an application as you remember it from last year.

For some reason, you're not adding the panel to the frame. Try changing your main method, adding the statement,

frame.add( panel );

before the frame.pack(); statement.

Does that look familiar?



Yes it does look familiar. I hate this school I'm going to. They make you do the programs off of templates of already existing code, and I dont do that, I try to create my own. But yes that does look familiar. Ok, so when I add that line, it works in Eclipse, but doesn't work in TextPad, it says cannot find symbol. Like I'm trying to call a vvariable or something. That program sucks! Do you know why it is saying that?

NVM, its because it pays attention to "white space." POS....LOL
Was This Post Helpful? 0
  • +
  • -

#13 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 02:30 PM

Interesting. I have no experience with running source code from TextPad, but that doesn't sound right.

Anyway. I assume you still need help turning it into an Applet? The simplest thing to do, just to get results that you can massage, is to modify your CrayonBox class: extending JApplet and adding the init() method that it needs (hence your original error). You can apply any other lessons from that link I provided you earlier to clean/pretty things up. The result that should run as an Applet in your HTML doc should look something like:
import javax.swing.*;
import java.awt.*;

public class CrayonBox extends JApplet
{
   public static void main (String[] args)
   {
      JFrame frame = new JFrame ("CrayonBox");
      frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

      CrayonPanel panel = new CrayonPanel();

      frame.pack();
      frame.setVisible(true);
   }
   
   public void init()
   {
       setContentPane( new CrayonPanel() );
   }
   
}

In that form, it should run as either a Java application or an Applet.
Was This Post Helpful? 1
  • +
  • -

#14 Chausse420  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 22-October 12

Re: Error: Start: Applett not initialized.

Posted 23 October 2012 - 02:38 PM

I just want to say, Thank You very much Mr. Greg Brannon. Your guidance has helped me tramendously and I now know how to make something run as both applet's and applications! Thanks so much!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1