home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD 31 / SUPERCDa.iso / Inet / HotJava / hjava.exe / Windows / resource / jre / lib / rt.jar / java / awt / Frame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-11  |  5.6 KB  |  277 lines

  1. package java.awt;
  2.  
  3. import java.awt.event.InputEvent;
  4. import java.awt.event.KeyEvent;
  5. import java.awt.peer.FramePeer;
  6. import java.io.IOException;
  7. import java.io.ObjectInputStream;
  8. import java.io.ObjectOutputStream;
  9. import java.util.Vector;
  10.  
  11. public class Frame extends Window implements MenuContainer {
  12.    public static final int DEFAULT_CURSOR = 0;
  13.    public static final int CROSSHAIR_CURSOR = 1;
  14.    public static final int TEXT_CURSOR = 2;
  15.    public static final int WAIT_CURSOR = 3;
  16.    public static final int SW_RESIZE_CURSOR = 4;
  17.    public static final int SE_RESIZE_CURSOR = 5;
  18.    public static final int NW_RESIZE_CURSOR = 6;
  19.    public static final int NE_RESIZE_CURSOR = 7;
  20.    public static final int N_RESIZE_CURSOR = 8;
  21.    public static final int S_RESIZE_CURSOR = 9;
  22.    public static final int W_RESIZE_CURSOR = 10;
  23.    public static final int E_RESIZE_CURSOR = 11;
  24.    public static final int HAND_CURSOR = 12;
  25.    public static final int MOVE_CURSOR = 13;
  26.    String title;
  27.    Image icon;
  28.    MenuBar menuBar;
  29.    boolean resizable;
  30.    boolean mbManagement;
  31.    Vector ownedWindows;
  32.    private static final String base = "frame";
  33.    private static int nameCounter;
  34.    private static final long serialVersionUID = 2673458971256075116L;
  35.    private int frameSerializedDataVersion;
  36.  
  37.    public Frame() {
  38.       this("");
  39.    }
  40.  
  41.    public Frame(String var1) {
  42.       this.title = "Untitled";
  43.       this.resizable = true;
  44.       this.mbManagement = false;
  45.       this.frameSerializedDataVersion = 1;
  46.       this.title = var1;
  47.       super.visible = false;
  48.       ((Container)this).setLayout(new BorderLayout());
  49.    }
  50.  
  51.    String constructComponentName() {
  52.       return "frame" + nameCounter++;
  53.    }
  54.  
  55.    Window addOwnedWindow(Window var1) {
  56.       if (var1 != null) {
  57.          if (this.ownedWindows == null) {
  58.             this.ownedWindows = new Vector();
  59.          }
  60.  
  61.          this.ownedWindows.addElement(var1);
  62.       }
  63.  
  64.       return var1;
  65.    }
  66.  
  67.    void removeOwnedWindow(Window var1) {
  68.       if (var1 != null && this.ownedWindows != null) {
  69.          this.ownedWindows.removeElement(var1);
  70.       }
  71.  
  72.    }
  73.  
  74.    public void addNotify() {
  75.       Object var1 = ((Component)this).getTreeLock();
  76.       synchronized(var1){}
  77.  
  78.       try {
  79.          if (super.peer == null) {
  80.             super.peer = ((Window)this).getToolkit().createFrame(this);
  81.          }
  82.  
  83.          MenuBar var3 = this.menuBar;
  84.          if (var3 != null) {
  85.             var3.addNotify();
  86.             ((FramePeer)super.peer).setMenuBar(var3);
  87.          }
  88.  
  89.          super.addNotify();
  90.       } catch (Throwable var5) {
  91.          throw var5;
  92.       }
  93.  
  94.    }
  95.  
  96.    public String getTitle() {
  97.       return this.title;
  98.    }
  99.  
  100.    public synchronized void setTitle(String var1) {
  101.       this.title = var1;
  102.       FramePeer var2 = (FramePeer)super.peer;
  103.       if (var2 != null) {
  104.          var2.setTitle(var1);
  105.       }
  106.  
  107.    }
  108.  
  109.    public Image getIconImage() {
  110.       return this.icon;
  111.    }
  112.  
  113.    public synchronized void setIconImage(Image var1) {
  114.       this.icon = var1;
  115.       FramePeer var2 = (FramePeer)super.peer;
  116.       if (var2 != null) {
  117.          var2.setIconImage(var1);
  118.       }
  119.  
  120.    }
  121.  
  122.    public MenuBar getMenuBar() {
  123.       return this.menuBar;
  124.    }
  125.  
  126.    public void setMenuBar(MenuBar var1) {
  127.       Object var2 = ((Component)this).getTreeLock();
  128.       synchronized(var2){}
  129.  
  130.       try {
  131.          if (this.menuBar != var1) {
  132.             if (var1 != null && var1.parent != null) {
  133.                var1.parent.remove(var1);
  134.             }
  135.  
  136.             if (this.menuBar != null) {
  137.                this.remove(this.menuBar);
  138.             }
  139.  
  140.             this.menuBar = var1;
  141.             if (this.menuBar != null) {
  142.                this.menuBar.parent = this;
  143.                FramePeer var4 = (FramePeer)super.peer;
  144.                if (var4 != null) {
  145.                   this.mbManagement = true;
  146.                   this.menuBar.addNotify();
  147.                   var4.setMenuBar(this.menuBar);
  148.                }
  149.             }
  150.  
  151.             ((Container)this).invalidate();
  152.             return;
  153.          }
  154.       } catch (Throwable var6) {
  155.          throw var6;
  156.       }
  157.  
  158.    }
  159.  
  160.    public boolean isResizable() {
  161.       return this.resizable;
  162.    }
  163.  
  164.    public synchronized void setResizable(boolean var1) {
  165.       this.resizable = var1;
  166.       FramePeer var2 = (FramePeer)super.peer;
  167.       if (var2 != null) {
  168.          var2.setResizable(var1);
  169.       }
  170.  
  171.    }
  172.  
  173.    public void remove(MenuComponent var1) {
  174.       Object var2 = ((Component)this).getTreeLock();
  175.       synchronized(var2){}
  176.  
  177.       try {
  178.          if (var1 == this.menuBar) {
  179.             this.menuBar = null;
  180.             FramePeer var4 = (FramePeer)super.peer;
  181.             if (var4 != null) {
  182.                this.mbManagement = true;
  183.                var4.setMenuBar((MenuBar)null);
  184.                var1.removeNotify();
  185.             }
  186.  
  187.             var1.parent = null;
  188.          } else {
  189.             super.remove(var1);
  190.          }
  191.       } catch (Throwable var6) {
  192.          throw var6;
  193.       }
  194.  
  195.    }
  196.  
  197.    public void dispose() {
  198.       Object var1 = ((Component)this).getTreeLock();
  199.       synchronized(var1){}
  200.  
  201.       try {
  202.          if (this.ownedWindows != null) {
  203.             int var3 = this.ownedWindows.size();
  204.             Window[] var4 = new Window[var3];
  205.             this.ownedWindows.copyInto(var4);
  206.  
  207.             for(int var5 = 0; var5 < var3; ++var5) {
  208.                var4[var5].dispose();
  209.             }
  210.          }
  211.  
  212.          if (this.menuBar != null) {
  213.             this.remove(this.menuBar);
  214.             this.menuBar = null;
  215.          }
  216.       } catch (Throwable var7) {
  217.          throw var7;
  218.       }
  219.  
  220.       super.dispose();
  221.    }
  222.  
  223.    void postProcessKeyEvent(KeyEvent var1) {
  224.       if (this.menuBar != null && this.menuBar.handleShortcut(var1)) {
  225.          ((InputEvent)var1).consume();
  226.       } else {
  227.          super.postProcessKeyEvent(var1);
  228.       }
  229.    }
  230.  
  231.    protected String paramString() {
  232.       String var1 = super.paramString();
  233.       if (this.resizable) {
  234.          var1 = var1 + ",resizable";
  235.       }
  236.  
  237.       if (this.title != null) {
  238.          var1 = var1 + ",title=" + this.title;
  239.       }
  240.  
  241.       return var1;
  242.    }
  243.  
  244.    /** @deprecated */
  245.    public synchronized void setCursor(int var1) {
  246.       if (var1 >= 0 && var1 <= 13) {
  247.          ((Component)this).setCursor(Cursor.getPredefinedCursor(var1));
  248.       } else {
  249.          throw new IllegalArgumentException("illegal cursor type");
  250.       }
  251.    }
  252.  
  253.    /** @deprecated */
  254.    public int getCursorType() {
  255.       return ((Component)this).getCursor().getType();
  256.    }
  257.  
  258.    private void writeObject(ObjectOutputStream var1) throws IOException {
  259.       var1.defaultWriteObject();
  260.    }
  261.  
  262.    private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
  263.       var1.defaultReadObject();
  264.       if (this.menuBar != null) {
  265.          this.menuBar.parent = this;
  266.       }
  267.  
  268.       if (this.ownedWindows != null) {
  269.          for(int var2 = 0; var2 < this.ownedWindows.size(); ++var2) {
  270.             Window var3 = (Window)this.ownedWindows.elementAt(var2);
  271.             var3.parent = this;
  272.          }
  273.       }
  274.  
  275.    }
  276. }
  277.