要从JFrameapplet 打开一个新的Java窗口(),请参阅Java教程中的以下摘录:
//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);
Run Code Online (Sandbox Code Playgroud)
要打开一个包含applet的新浏览器窗口showDocument(URL, "_blank"):
URL url = new URL(getCodeBase().getProtocol(),
getCodeBase().getHost(),
getCodeBase().getPort(),
"/next.html");
getAppletContext().showDocument(url, "_blank");
Run Code Online (Sandbox Code Playgroud)