//: c15:ShowHTML.java // Przykład z książki 'Thinking in Java, wydanie 2.', autor - Bruce Eckel // www.BruceEckel.com. // Patrz informacje o prawach autorskich podane w pliku CopyRight.txt. // <applet code=ShowHTML width=100 height=50> // </applet> import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.net.*; import java.io.*; import com.bruceeckel.swing.*; public class ShowHTML extends JApplet { JButton send = new JButton("Przejdź"); JLabel l = new JLabel(); public void init() { Container cp = getContentPane(); cp.setLayout(new FlowLayout()); send.addActionListener(new Al()); cp.add(send); cp.add(l); } class Al implements ActionListener { public void actionPerformed(ActionEvent ae) { try { // Zamiast strony HTML mógłby tu być // program CGI. URL u = new URL(getDocumentBase(), "FetcherFrame.html"); // Wyświetl wyjście dla danego adresu URL // za pomocą przeglądarki, jak zwykłą stronę: getAppletContext().showDocument(u); } catch(Exception e) { l.setText(e.toString()); } } } public static void main(String[] args) { Console.run(new ShowHTML(), 100, 50); } } ///:~