如何将 Swing 应用程序转换为 Applet?
我使用 Swing 应用程序框架创建了一个桌面应用程序,现在如何将其转换为小程序? 主类扩展了 SingleFrameApplication。
编辑:这是起始类,使用 NetBeans GUI 构建器:
public class PhotoApp extends SingleFrameApplication {
/**
* At startup create and show the main frame of the application.
*/
@Override protected void startup() {
show(new PhotoView(this));
}
/**
* This method is to initialize the specified window by injecting resources.
* Windows shown in our application come fully initialized from the GUI
* builder, so this additional configuration is not needed.
*/
@Override protected void configureWindow(java.awt.Window root) {
}
/**
* A convenient static getter for the application instance.
* @return the instance of PhotoUploaderApp
*/
public static PhotoApp getApplication() {
return Application.getInstance(PhotoApp.class);
}
/**
* Main method launching the application.
*/
public static void main(String[] args) {
launch(PhotoApp.class, args);
}
}
I created a desktop application with Swing Application Framework, now how can I convert it to an applet? The main class extends SingleFrameApplication.
EDITED: This is the starting class, used NetBeans GUI builder:
public class PhotoApp extends SingleFrameApplication {
/**
* At startup create and show the main frame of the application.
*/
@Override protected void startup() {
show(new PhotoView(this));
}
/**
* This method is to initialize the specified window by injecting resources.
* Windows shown in our application come fully initialized from the GUI
* builder, so this additional configuration is not needed.
*/
@Override protected void configureWindow(java.awt.Window root) {
}
/**
* A convenient static getter for the application instance.
* @return the instance of PhotoUploaderApp
*/
public static PhotoApp getApplication() {
return Application.getInstance(PhotoApp.class);
}
/**
* Main method launching the application.
*/
public static void main(String[] args) {
launch(PhotoApp.class, args);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
快速但肮脏的方法:
Drop 扩展 SingleFrameApplication。
添加扩展 JApplet。
将构造函数替换为 public void init()
让身体保持原样。
创建一个 HTML 页面来保存它。 并尝试一下。
可能会出现一些范围问题,但您应该能够相当轻松地解决这些问题。
The quick and dirty way:
Drop extends SingleFrameApplication.
Add extends JApplet.
replace the constructor with public void init()
leaving the body as is.
Create an HTML page to hold it. and give it a whirl.
There will likely be some scoping issues, but you should be able to fix those fairly easily.
最简单的事情就是创建一个继承自 JApplet 的新外部类,并实例化其中的实际框架。
更新
发现在线教程可以提供帮助。
Simplest thing is just to make a new outer class inheriting from JApplet, and instantiate the actual frame inside it.
Update
Found a tutorial online that could help.