Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1225733

Applets can't be run as applications

    XMLWordPrintable

Details

    • 1.0beta
    • sparc
    • generic
    • Not verified

    Description

      You can no longer write a program that executes both as an applet
      and as an application -- at least if you use the resize() method in
      your Applet subclass. Arthur says that the problem is that the parent
      of the AppletPanel doesn't know about resizing.

      This has a major impact because all my examples for the UI chapter
      work both as applets and applications, and all my screenshots are of
      the applications.

      Here's a little program that should work but doesn't. I've got lots
      more....

      import java.awt.*;
      import java.util.*;
      import java.applet.Applet;

      public class BorderEx1 extends Applet {
          public void init() {
      setLayout(new BorderLayout());
               setFont(new Font("Helvetica", Font.PLAIN, 14));
         
      add("North", new Button("North"));
      add("South", new Button("South"));
      add("East", new Button("East"));
      add("West", new Button("West"));
      add("Center", new Button("Center"));

              resize(300, 100);
          }

          public static void main(String args[]) {
      Frame f = new Frame("Border Layout Example");
      BorderEx1 ex1 = new BorderEx1();

      ex1.init();

      f.add("Center", ex1);
      f.pack();
      f.resize(f.preferredSize());
      f.show();
          }
      }

      Attachments

        Activity

          People

            ahoffsunw Arthur Hoff (Inactive)
            kwalrathsunw Kathy Walrath (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: