[JAVA] Rewriting from applet to application

Change from Applet class to Frame class

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);
}

The story of getting this knowledge

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

Rewriting from applet to application
Connect to Aurora (MySQL) from a Java application
Changes from Java 8 to Java 11
Sum from Java_1 to 100
Migrate from JUnit 4 to JUnit 5
From Java to Ruby !!
Push delivery from Spring application to Firebase Cloud Messaging
Moved from iBATIS to MyBatis3
How to create an application
I tried to make an application in 3 months from inexperienced
Try Spring Boot from 0 to 100.
Migration from Cobol to JAVA
Switch from slim3-gen to slim3-gen-jsr269
Introduction to Android application development
New features from Java7 to Java8
Migrating from vargrant to docker
From studying programming for 2 months to releasing a web application
Connect from Java to PostgreSQL
Convert from ○ months to ○ years ○ months
Deploy your application to WildFly
Change from SQLite3 to PostgreSQL
From Ineffective Java to Effective Java
How to migrate from JUnit4 to JUnit5
Ruby on Rails --From environment construction to simple application development on WSL2
How to build an Apache Flink application from scratch in 5 minutes
Try to introduce OpenCV to Android application
How to push from Tarminal to GitHub
protocol buffeer migration from 2.x to 3.x
Preparing to create a Rails application
[Note] Download from S3, upload to S3
Stop resending from client to server
Ubuntu Desktop upgrade from 18.0.4 (?) To 20.04.1 (focal)
Access Teradata from a Java application
Migrate from on-premise Pukiwiki to esa.io \ (⁰⊖⁰) /
From introduction to use of ActiveHash
Switch from JSP + JSTL to Thymeleaf
From Java to VB.NET-Writing Contrast Memo-
Introduction to Ruby (from other languages)
Java, interface to start from beginner
Change DB from SQLite to MySQL
Notes on migrating from CircleCI 1.0 to 2.0
Addicted to project imports from GitHub
Upgrade spring boot from 1.5 series to 2.0 series
We aim to update daily from 2021
From introduction to usage of byebug
Switch from Eclipse to VS Code
Deploy SpringBoot application to AWS EC2
The road from JavaScript to Java
Memorandum Poem (updated from time to time)
[Java] Conversion from array to List
Update MySQL from 5.7 to 8.0 with Docker
How to change from HTML to Haml