Jump to content
  • Advertisement
Sign in to follow this  
Alpha_ProgDes

Applet question

This topic is 4118 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
Advertisement
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
I see. Thank you. I found out through some tinkering that Applet, as opposed to JApplet, can use paintComponent() as well. But thanks for the info.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!