home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / awt / Frame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  5.5 KB  |  274 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.       super.name = "frame" + nameCounter++;
  47.       this.title = var1;
  48.       super.visible = false;
  49.       ((Container)this).setLayout(new BorderLayout());
  50.    }
  51.  
  52.    Window addOwnedWindow(Window var1) {
  53.       if (var1 != null) {
  54.          if (this.ownedWindows == null) {
  55.             this.ownedWindows = new Vector();
  56.          }
  57.  
  58.          this.ownedWindows.addElement(var1);
  59.       }
  60.  
  61.       return var1;
  62.    }
  63.  
  64.    void removeOwnedWindow(Window var1) {
  65.       if (var1 != null && this.ownedWindows != null) {
  66.          this.ownedWindows.removeElement(var1);
  67.       }
  68.  
  69.    }
  70.  
  71.    public void addNotify() {
  72.       Object var1 = ((Component)this).getTreeLock();
  73.       synchronized(var1){}
  74.  
  75.       try {
  76.          if (super.peer == null) {
  77.             super.peer = ((Window)this).getToolkit().createFrame(this);
  78.          }
  79.  
  80.          MenuBar var3 = this.menuBar;
  81.          if (var3 != null) {
  82.             var3.addNotify();
  83.             ((FramePeer)super.peer).setMenuBar(var3);
  84.          }
  85.  
  86.          super.addNotify();
  87.       } catch (Throwable var5) {
  88.          throw var5;
  89.       }
  90.  
  91.    }
  92.  
  93.    public String getTitle() {
  94.       return this.title;
  95.    }
  96.  
  97.    public synchronized void setTitle(String var1) {
  98.       this.title = var1;
  99.       FramePeer var2 = (FramePeer)super.peer;
  100.       if (var2 != null) {
  101.          var2.setTitle(var1);
  102.       }
  103.  
  104.    }
  105.  
  106.    public Image getIconImage() {
  107.       return this.icon;
  108.    }
  109.  
  110.    public synchronized void setIconImage(Image var1) {
  111.       this.icon = var1;
  112.       FramePeer var2 = (FramePeer)super.peer;
  113.       if (var2 != null) {
  114.          var2.setIconImage(var1);
  115.       }
  116.  
  117.    }
  118.  
  119.    public MenuBar getMenuBar() {
  120.       return this.menuBar;
  121.    }
  122.  
  123.    public void setMenuBar(MenuBar var1) {
  124.       Object var2 = ((Component)this).getTreeLock();
  125.       synchronized(var2){}
  126.  
  127.       try {
  128.          if (this.menuBar != var1) {
  129.             if (var1 != null && var1.parent != null) {
  130.                var1.parent.remove(var1);
  131.             }
  132.  
  133.             if (this.menuBar != null) {
  134.                this.remove(this.menuBar);
  135.             }
  136.  
  137.             this.menuBar = var1;
  138.             if (this.menuBar != null) {
  139.                this.menuBar.parent = this;
  140.                FramePeer var4 = (FramePeer)super.peer;
  141.                if (var4 != null) {
  142.                   this.mbManagement = true;
  143.                   this.menuBar.addNotify();
  144.                   var4.setMenuBar(this.menuBar);
  145.                }
  146.             }
  147.  
  148.             ((Container)this).invalidate();
  149.             return;
  150.          }
  151.       } catch (Throwable var6) {
  152.          throw var6;
  153.       }
  154.  
  155.    }
  156.  
  157.    public boolean isResizable() {
  158.       return this.resizable;
  159.    }
  160.  
  161.    public synchronized void setResizable(boolean var1) {
  162.       this.resizable = var1;
  163.       FramePeer var2 = (FramePeer)super.peer;
  164.       if (var2 != null) {
  165.          var2.setResizable(var1);
  166.       }
  167.  
  168.    }
  169.  
  170.    public void remove(MenuComponent var1) {
  171.       Object var2 = ((Component)this).getTreeLock();
  172.       synchronized(var2){}
  173.  
  174.       try {
  175.          if (var1 == this.menuBar) {
  176.             FramePeer var4 = (FramePeer)super.peer;
  177.             if (var4 != null) {
  178.                this.mbManagement = true;
  179.                this.menuBar.removeNotify();
  180.                var4.setMenuBar((MenuBar)null);
  181.             }
  182.  
  183.             this.menuBar.parent = null;
  184.             this.menuBar = null;
  185.          } else {
  186.             super.remove(var1);
  187.          }
  188.       } catch (Throwable var6) {
  189.          throw var6;
  190.       }
  191.  
  192.    }
  193.  
  194.    public void dispose() {
  195.       Object var1 = ((Component)this).getTreeLock();
  196.       synchronized(var1){}
  197.  
  198.       try {
  199.          if (this.ownedWindows != null) {
  200.             int var3 = this.ownedWindows.size();
  201.             Window[] var4 = new Window[var3];
  202.             this.ownedWindows.copyInto(var4);
  203.  
  204.             for(int var5 = 0; var5 < var3; ++var5) {
  205.                var4[var5].dispose();
  206.             }
  207.          }
  208.  
  209.          if (this.menuBar != null) {
  210.             this.remove(this.menuBar);
  211.             this.menuBar = null;
  212.          }
  213.       } catch (Throwable var7) {
  214.          throw var7;
  215.       }
  216.  
  217.       super.dispose();
  218.    }
  219.  
  220.    void postProcessKeyEvent(KeyEvent var1) {
  221.       if (this.menuBar != null && this.menuBar.handleShortcut(var1)) {
  222.          ((InputEvent)var1).consume();
  223.       } else {
  224.          super.postProcessKeyEvent(var1);
  225.       }
  226.    }
  227.  
  228.    protected String paramString() {
  229.       String var1 = super.paramString();
  230.       if (this.resizable) {
  231.          var1 = var1 + ",resizable";
  232.       }
  233.  
  234.       if (this.title != null) {
  235.          var1 = var1 + ",title=" + this.title;
  236.       }
  237.  
  238.       return var1;
  239.    }
  240.  
  241.    /** @deprecated */
  242.    public synchronized void setCursor(int var1) {
  243.       if (var1 >= 0 && var1 <= 13) {
  244.          ((Component)this).setCursor(Cursor.getPredefinedCursor(var1));
  245.       } else {
  246.          throw new IllegalArgumentException("illegal cursor type");
  247.       }
  248.    }
  249.  
  250.    /** @deprecated */
  251.    public int getCursorType() {
  252.       return ((Component)this).getCursor().getType();
  253.    }
  254.  
  255.    private void writeObject(ObjectOutputStream var1) throws IOException {
  256.       var1.defaultWriteObject();
  257.    }
  258.  
  259.    private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
  260.       var1.defaultReadObject();
  261.       if (this.menuBar != null) {
  262.          this.menuBar.parent = this;
  263.       }
  264.  
  265.       if (this.ownedWindows != null) {
  266.          for(int var2 = 0; var2 < this.ownedWindows.size(); ++var2) {
  267.             Window var3 = (Window)this.ownedWindows.elementAt(var2);
  268.             var3.parent = this;
  269.          }
  270.       }
  271.  
  272.    }
  273. }
  274.