Sign in to follow this  

Applet question

This topic is 3931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Why would I use this:
import java.awt.*;
import java.applet.*;

public class Ch2 extends Applet {
	
	public void init() {
	}

	public void paint(Graphics g) {
		
		g.drawString("Welcome to Java!!", 50, 60 );
		
	}
}
Instead of this:
import javax.swing.JApplet.*;
import java.awt.*;

public class Ch2 extends JApplet {
	
	public void init() {
	}

	public void paint(Graphics g) {
		
		g.drawString("Welcome to Java!!", 50, 60 );
		
	}
}

Share this post


Link to post
Share on other sites
Quick search turned up these differences:

Quote:
JApplet vs. Applet

* JApplet inherits from Applet
* Basic functionality, init, start, stop, etc. is the same.
* Components go in the "content pane", not directly in the frame.
* Changing other properties (layout manager, background color, etc.) also apply to the content pane.
* Access content pane via getContentPane, or if you want to replace it with your container (e.g. a JPanel), use setContentPane.
* Default layout manager is BorderLayout (like Frame and JFrame), not FlowLayout (like Applet). This is really the layout manager of the content pane.
* You get Java (Metal) look by default, so you have to explicitly switch if you want native look.
* Do drawing in paintComponent, not paint.
* Double buffering turned on by default.

Share this post


Link to post
Share on other sites

This topic is 3931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this