0

For my class we are asked to create a holiday-themed applet. I am very far ahead in my knowledge of Java than the rest of the class because I have been working in it for a few months experimenting with AWT and a little Swing. As far as applets go, I have little experience rather than painting the page.

In class, I noticed that we set up the applet to draw in as follows:

import java.applet.Applet;
import java.awt.*;
public class ChristmasApplet extends Applet
{
   public void paint(Graphics g){

   }
}

Whereas the default for the applet is as follows:

import java.awt.*;
import javax.swing.*;
public class ChristmasApplet extends JApplet
{
   public void paint(Graphics g){

   }
}

So my question is, what is the difference between these two setups? What is each used for specifically and what can and can't I do with each one?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
VTedd
  • 5
  • 3
  • Why code an applet? If it is due to spec. by teacher, please refer them to [Why CS teachers should stop teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). – Andrew Thompson Dec 14 '13 at 20:15
  • 1
    Just sent an email to my teacher about this...thank you. – VTedd Dec 14 '13 at 20:47
  • *"Just sent an email to my teacher about this."* Thank you, thank you, and thank you. I wrote the blog article and have posted that comment (probably) 100s of times since then, and mostly get *completely ignored.* The world will be a better place (in some small way) if we can bring this teacher around. It's a start. :-) – Andrew Thompson Dec 14 '13 at 20:49
  • 1
    My school's CS program is very undeveloped right now, only consisting of a VB class and a Java class, each with around 10-15 guys in them. The good news to this is that my teacher is very open minded about how to make the program better and I can only assume he will be more than willing to change around the program to better fit the needs of students looking to major in CS like myself. – VTedd Dec 14 '13 at 20:55

1 Answers1

1

what is the difference between these two setups?

The first is AWT, the 2nd is Swing.

Use Swing rather than AWT. See this answer on Swing extras over AWT for many good reasons to abandon using AWT components. If you need to support older AWT based APIs, see Mixing Heavyweight and Lightweight Components.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433