Как открыть новое окно апплета от апплета

как я могу открыть новое окно апплета от самого апплета?

6
задан Chern 12 March 2010 в 17:18
поделиться

1 ответ

Чтобы открыть новое окно Java ( JFrame ) из апплета, см. Следующий отрывок из учебного пособия по 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);

Чтобы открыть новое окно браузера, которое также содержит апплет showDocument (URL, "_blank") :

URL url = new URL(getCodeBase().getProtocol(),
                      getCodeBase().getHost(),
                      getCodeBase().getPort(),
                      "/next.html");
getAppletContext().showDocument(url, "_blank");
6
ответ дан 17 December 2019 в 02:27
поделиться
Другие вопросы по тегам:

Похожие вопросы: