java - 如何从小程序打开新的小程序窗口

标签 java applet

如何从小程序本身打开一个新的小程序窗口?

最佳答案

要从小程序打开一个新的 Java 窗口 (JFrame),请参阅以下摘自 Java tutorial 的内容:

//1. Create the frame.
JFrame frame = new JFrame("FrameDemo");

//2. Optional: What happens when the frame closes?
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//3. Create components and put them in the frame.
//...create emptyLabel...
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);

//4. Size the frame.
frame.pack();

//5. Show it.
frame.setVisible(true);

打开一个新的浏览器窗口,其中也包含一个小程序 showDocument(URL, "_blank") :

URL url = new URL(getCodeBase().getProtocol(),
                      getCodeBase().getHost(),
                      getCodeBase().getPort(),
                      "/next.html");
getAppletContext().showDocument(url, "_blank");

关于java - 如何从小程序打开新的小程序窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2434483/

相关文章:

java - Mac 上的简单 Java 编译错误 : Trying to use Scanner Class for data input at command prompt?

java - 为什么我们需要覆盖父类的方法?

java - 将 Jpanel 上的绘图保存为图像

java - 强制小程序仅加载一次

java - 线程中的异常 "AWT-EventQueue-0"java.lang.ArrayIndexOutOfBoundsException : 10 for Inventory

java - 从小程序调用 JS 在 Firefox 和 Chrome 中有效,但在 Safari 中无效

java - 如何将位图背景替换为特定颜色

java - Java中是否有内置方法可以将字符串转换为整数数组?

macos - Java Applet 在 Safari 中沙箱化?

java - 字符串返回标签而不是格式化文本