1 / 86

Java's Graphical User Interface Toolkit

Java's Graphical User Interface Toolkit. Windows, Applets and all that Swings. What is Swing?. A Swing Tour. A Tour of Swing. The Agenda. Display A Simple Window from main(). Display A Window from an Object. Display an Object that is a Window. Display an Applet Object.

chin
Télécharger la présentation

Java's Graphical User Interface Toolkit

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java'sGraphical User InterfaceToolkit Windows, Applets and all that Swings.

  2. What is Swing? A Swing Tour

  3. A Tour of Swing The Agenda Display A Simple Window from main() Display A Window from an Object Display an Object that is a Window Display an Applet Object Laying out Display Components Making Buttons and Stuff Work

  4. Starting with an Example The Basic Window

  5. The Basic JFrame import javax.swing.*; class BasicJFrame { public static void main(String[] args) { JFrame jf = new JFrame("The Basic JFrame"); jf.setSize(250,250); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setVisible(true); } }

  6. The Basic JFrame import javax.swing.*; class BasicJFrame { public static void main(String[] args) { JFrame jf = new JFrame("The Basic JFrame"); jf.setSize(250,250); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setVisible(true); } }

  7. jf = new JFrame("The Basic JFrame") Setting the title with the constructor.

  8. jf.setSize(250, 250) 250 pixels 250 pixels

  9. jf.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE); Causes the thread for the JFrame to terminate when window closed.

  10. jf.setVisible(true);

  11. Adding The JPanel import javax.swing.*; class BasicJFrame { public static void main(String[] args) { JFrame jf = new JFrame("The Basic JFrame"); jf.setSize(250,250); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setVisible(true); } } import javax.swing.*; class DoJPanel { public static void main(String[] args) { JFrame jf = new JFrame("The Basic JFrame"); jf.setSize(250,250); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jp = new JPanel(); jf.getContentPane().add(jp); jf.setVisible(true); } } import javax.swing.*; class DoJPanel { public static void main(String[] args) { JFrame jf = new JFrame("The Basic JFrame"); jf.setSize(250,250); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jp = new JPanel(); jf.getContentPane().add(jp); jf.setVisible(true); } }

  12. jf.getContentPane()

  13. Jpanel jp = new Jpanel();jf.getContentPane().add(jp); JPanel

  14. Top Level Containers • JFrame • JDialog • JApplet • JWindow • JInternalFrame

  15. How do I Build a Display Object? An Object That Displays a Window

  16. MyWindow public class DoMyWindow { public static void main(String[] args) { new MyWindow(); } } public class MyWindow { • • • }

  17. public class MyWindow { } MyWindow Required but not shown. import javax.swing.*; import java.awt.event.*;

  18. public class MyWindow { MyWindow() { } } MyWindow Create all the new GUI objects and their references as members here. Assemble the GUI objects in the constructor.

  19. public class MyWindow { JFrame jf = new JFrame("MyWindow"); MyWindow() { } } MyWindow

  20. public class MyWindow { JFrame jf = new JFrame("MyWindow"); MyWindow() { jf.setVisible(true); } } MyWindow

  21. public class MyWindow { JFrame jf = new JFrame("MyWindow"); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setVisible(true); } } MyWindow

  22. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setVisible(true); } } MyWindow

  23. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jf.setVisible(true); } } MyWindow

  24. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jf.setVisible(true); } } MyWindow

  25. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jf.setVisible(true); } } MyWindow

  26. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jf.setVisible(true); } } MyWindow

  27. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jf.setVisible(true); } } MyWindow

  28. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jf.setVisible(true); } } MyWindow

  29. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jf.getContentPane().add(jp); jf.setVisible(true); } } MyWindow

  30. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jf.getContentPane().add(jp); jf.setVisible(true); } } MyWindow

  31. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jf.getContentPane().add(jp); jp.add(jtf); jf.setVisible(true); } } MyWindow

  32. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); } } MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jf.getContentPane().add(jp); jp.add(jtf); jf.setVisible(true); } } MyWindow

  33. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); } } MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); jf.getContentPane().add(jp); jp.add(jtf); jf.setVisible(true); } } MyWindow

  34. public class MyWindow { JFrame jf = new JFrame("MyWindow"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } MyWindow() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); jf.getContentPane().add(jp); jp.add(jtf); jf.setVisible(true); } } MyWindow

  35. How Do I Make an Object Visible? Making an Object Display Itself

  36. A Change in Structure • MyWindow • Creates a JFrame Object • Fills it With Other GUI Objects • Displays the Finished JFrame • MyWindow2 • Is a JFrame Object • Fill Itself With Other GUI Objects • MyWindow Displays Itself

  37. MyWindow2 public class DoMyWindow2 { public static void main(String[] args) { new MyWindow2(); } } public class MyWindow2 { • • • }

  38. public class MyWindow2 { JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } MyWindow2() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); jf.getContentPane().add(jp); jp.add(jtf); jf.setVisible(true); } } public class MyWindow2 { JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } MyWindow2() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); jf.getContentPane().add(jp); jp.add(jtf); jf.setVisible(true); } } public class MyWindow2 { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } MyWindow2() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); jf.getContentPane().add(jp); jp.add(jtf); jf.setVisible(true); } } public class MyWindow2 extends JFrame { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } MyWindow2() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); jf.getContentPane().add(jp); jp.add(jtf); jf.setVisible(true); } } public class MyWindow2 extends JFrame { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } MyWindow2() { jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); jf.getContentPane().add(jp); jp.add(jtf); jf.setVisible(true); } } public class MyWindow2 extends JFrame { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } MyWindow2() { setSize(500, 100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); getContentPane().add(jp); jp.add(jtf); setVisible(true); } } MyWindow2

  39. How Do I Display an Object On the Web? Building an Applet

  40. public void init() public void start() public void stop() public void destroy() First (one) Time Initialization Called when the Applet becomes visible Called when the Applet becomes hidden Called when Applet is unloaded What the Browser Expects in an Applet

  41. SimpleApplet public class MyWindow2 extends JFrame { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } MyWindow2() { setSize(500, 100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); getContentPane().add(jp); add(jtf); setVisible(true); } } public class SimpleApplet extends JFrame { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } MyWindow2() { setSize(500, 100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); getContentPane().add(jp); add(jtf); setVisible(true); } } public class SimpleApplet extends JApplet { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } MyWindow2() { setSize(500, 100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); getContentPane().add(jp); add(jtf); setVisible(true); } } public class SimpleApplet extends JApplet { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } public void init() { setSize(500, 100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); getContentPane().add(jp); add(jtf); setVisible(true); } } public class SimpleApplet extends JApplet { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } public void init() { //setSize(500, 100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); getContentPane().add(jp); add(jtf); setVisible(true); } } public class SimpleApplet extends JApplet { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } public void init() { //setSize(500, 100); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); getContentPane().add(jp); add(jtf); setVisible(true); } } public class SimpleApplet extends JApplet { //JFrame jf = new JFrame("MyWindow2"); JMenuBar jmb = new JMenuBar(); JMenu jm = new JMenu("File"); JMenuItem jmi = new JMenuItem("Print Something Cute"); JPanel jp = new JPanel(); JTextField jtf = new JTextField("Try the File Menu"); int count = 0; class DoIt implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println("Something Cute"); jtf.setText("Count = " + ++count); } } public void init() { //setSize(500, 100); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setJMenuBar(jmb); jmb.add(jm); jm.add(jmi); jmi.addActionListener(new DoIt()); getContentPane().add(jp); add(jtf); //setVisible(true); } } MyWindow2 Required but not shown. import javax.swing.*; import java.awt.event.*;

  42. Running The Simple Applet • Run the Applet in a JFrame • Run the Applet in the Appletviewer • Build appropriate html file • C:\Chap13>appletviewer SimpleApplet.html • Run the Applet in a Web Browser • Build appropriate html file • Open html file with Browser

  43. MyWindow2 public class DoMyWindow2 { public static void main(String[] args) { new MyWindow2(); } } import javax.swing.*; import java.awt.event.*; public class SimpleApplet extends JApplet { • • • }

  44. An Applet Display Case import javax.swing.*; public class AppletDisplayCase { public static void main(String[] args) { JFrame jf = new JFrame("Applet Display Case"); jf.setSize(500, 100); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JApplet app = new SimpleApplet(); jf.getContentPane().add(app); app.init(); app.start(); jf.setVisible(true); } }

  45. Running The Simple Applet • Run the Applet in a JFrame • Run the Applet in the Appletviewer • Build appropriate html file • C:\Chap13>appletviewer SimpleApplet.html • Run the Applet in a Web Browser • Build appropriate html file • Open html file with Browser

  46. VerySimpleApplet.html <html><head><title>SimpleApplet</title></head> <H3>Demonstrating SimpleApplet</H3> <hr> <APPLET code="SimpleApplet.class" width="500" height="100" align="baseline" codebase="." > No Java 2 support for APPLET!! </APPLET> <hr></body></html>

  47. <html><head><title>SimpleApplet</title></head> <H3>Demonstrating SimpleApplet</H3> <hr> <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="500" height="100" align="baseline" codebase="http://javaweb.eng/plugin/ jre-1_3-win.exe#Version=1,3,0,0"> <PARAM NAME="code" VALUE="SimpleApplet.class"> <PARAM NAME="codebase" VALUE="."> <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> <COMMENT> <EMBED type="application/x-java-applet;version=1.3" width="500" height="100" align="baseline" code="SimpleApplet.class" codebase="." pluginspage="http://javaweb.eng/plugin/plugin-install.html"> <NOEMBED></COMMENT> No JDK 1.3 support for APPLET!! </NOEMBED> </EMBED> </OBJECT> <hr></body></html> <html><head><title>SimpleApplet</title></head> <H3>Demonstrating SimpleApplet</H3> <hr> <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="500" height="100" align="baseline" codebase="http://javaweb.eng/plugin/ jre-1_3-win.exe#Version=1,3,0,0"> <PARAM NAME="code" VALUE="SimpleApplet.class"> <PARAM NAME="codebase" VALUE="."> <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> <COMMENT> <EMBED type="application/x-java-applet;version=1.3" width="500" height="100" align="baseline" code="SimpleApplet.class" codebase="." pluginspage="http://javaweb.eng/plugin/plugin-install.html"> <NOEMBED></COMMENT> No JDK 1.3 support for APPLET!! </NOEMBED> </EMBED> </OBJECT> <hr></body></html> SimpleApplet.html

  48. All AboutRunning Applets In a Web Browser http://java.sun.com/products/plugin/1.3/docs/intranet.html http://java.sun.com/products/plugin/1.3/docs/tags.html

  49. Running The Simple Applet • Run the Applet in a JFrame • Run the Applet in the Appletviewer • Build appropriate html file • C:\Chap13>appletviewer SimpleApplet.html • Run the Applet in a Web Browser • Build appropriate html file • Open html file with Browser

  50. C:\Chap13>appletviewer SimpleApplet.htmlor C:\Chap13>appletviewer VerySimpleApplet.html

More Related