Introduction to applets : http://javatyro.blogspot.in/2013/07/introduction-to-applets.html
Converting applet into application in java:
Suppose the user who do not have a browser,he cannot execute an applet. So we must convert the applet to application. In general applications have the main() method.You can use the Frame class to convert the applet to application.
Applet's default layout manager is FlowLayout .But ,Frames default Layout manager is BorderLayout.
program for applet convertion.
import java.awt.*; import java.applet.*; import java.awt.event.*; public class convert extends Applet { public void paint(Graphics g) { setBackground(Color.pink); g.drawString("Applet to Application",10,10); g.drawString("ALT+F4 to close",10,40); } public static void main(String args[]) { myframe m=new myframe(); convert c=new convert(); c.init(); m.add("Center",c); m.show(); } } class myframe extends Frame { public myframe() { setTitle("Quit for close button"); setSize(300,200); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } }
Output of a Program:-
I love more comments...
ReplyDelete