This is a method to rewrite the applet to the application when the migration cannot be done by the simple method introduced in http://wisdom.sakura.ne.jp/system/java/awt/Gjava33.html. Change the inherited class from Applet to Frame, create a class with a main method, and call the Frame's init method from within, basically that's it. The example below is an example of the main method that runs the class FrameApplet, which changes the inherited class from Applet to Frame, as an application. I am adding the part that ends with the close button of the window. Replace x, y, width, and height in setBounds with arbitrary integers.
public static void main(String [] args )
{
FrameApplet frame = new FrameApplet();
frame.init();
frame.setBounds( x, y, width, height );
frame.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e)
{ System.exit(0);}
}
);
frame.setVisible(true);
}
In 2005, I made a Java applet program to be published for work. It is a form that distributes jar and html, has them placed locally, and executes them. At that time, Windows was in the XP era, and 98 was still in use. Assuming that various people will use the skills, including Mac, I thought that installation-free and platform-free would be good, so I made it with an applet. However, applets became narrower and narrower, and skills were required to use them. I was thinking of rewriting it as an application, but I had to make it as an applet in a special way (I didn't know how to do it smartly due to lack of skills), so I didn't know what to do and left it alone. Normally, you can easily do it using the main method (http://wisdom.sakura.ne.jp/system/java/awt/Gjava33.html). It seems, but a special method, specifically, two classes are running at the same time to communicate with each other, so this method simply could not be used. However, when I tried to raise my heavy waist this time, I was able to do it unexpectedly easily. I understand the merit of Java's structure that inherits from primitive classes and has various classes.
Recommended Posts