java - 直接运行 Java 小程序(无 html 页面)

标签 java applet

我有一个问题。

如何在不嵌入我的网页的情况下直接运行我的 java-applet?

我知道 appletViewr 可以在没有浏览器的情况下执行 applet,但我需要在没有 html 页面的情况下获取 java applet。

最佳答案

在您的代码中使用以下代码,其中 AppletClass 是您的 Applet 类。

AppletClass appletClass = new AppletClass ();

JFrame frame = new JFrame();
frame.setLayout(new GridLayout(1, 1));
frame.add(appletClass );

// Set frame size and other properties
...

// Call applet methods
appletClass .init();
appletClass .start();

frame.setVisible(true);

可以根据需要进行更多的定制。

关于java - 直接运行 Java 小程序(无 html 页面),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3012124/

相关文章:

java - Java 的 HTML 对象标记以针对特定版本

Java Applet 包装器规模输出

java - 使用 .jar Applet 加载资源

java - 无需类即可从跨度获取文本

java - Crystal Reports Java 报告组件 : no texts on diagrams on Linux machine (CentOS)

java - 从文本字段获取文本java fxml

java - 删除除 ""之外的所有空白字符

HTML 中嵌入 jar 的 Java Applet 安全问题

java - 使用 java 小程序查看 .doc 文件

java - 是否可以在同一个语句中同时运行 Try 和 Catch