home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / CHIPHEFT062001.ISO / browser / nc32lyc / comm.z / java40.jar / java / awt / Frame.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-08-15  |  5.4 KB  |  247 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.       if (super.peer == null) {
  73.          super.peer = ((Window)this).getToolkit().createFrame(this);
  74.       }
  75.  
  76.       MenuBar var1 = this.menuBar;
  77.       if (var1 != null) {
  78.          var1.addNotify();
  79.          ((FramePeer)super.peer).setMenuBar(var1);
  80.       }
  81.  
  82.       super.addNotify();
  83.    }
  84.  
  85.    public String getTitle() {
  86.       return this.title;
  87.    }
  88.  
  89.    public synchronized void setTitle(String var1) {
  90.       this.title = var1;
  91.       FramePeer var2 = (FramePeer)super.peer;
  92.       if (var2 != null) {
  93.          var2.setTitle(var1);
  94.       }
  95.  
  96.    }
  97.  
  98.    public Image getIconImage() {
  99.       return this.icon;
  100.    }
  101.  
  102.    public synchronized void setIconImage(Image var1) {
  103.       this.icon = var1;
  104.       FramePeer var2 = (FramePeer)super.peer;
  105.       if (var2 != null) {
  106.          var2.setIconImage(var1);
  107.       }
  108.  
  109.    }
  110.  
  111.    public MenuBar getMenuBar() {
  112.       return this.menuBar;
  113.    }
  114.  
  115.    public synchronized void setMenuBar(MenuBar var1) {
  116.       if (this.menuBar != var1) {
  117.          if (var1 != null && var1.parent != null) {
  118.             var1.parent.remove(var1);
  119.          }
  120.  
  121.          if (this.menuBar != null) {
  122.             this.remove(this.menuBar);
  123.          }
  124.  
  125.          this.menuBar = var1;
  126.          if (this.menuBar != null) {
  127.             this.menuBar.parent = this;
  128.             FramePeer var2 = (FramePeer)super.peer;
  129.             if (var2 != null) {
  130.                this.mbManagement = true;
  131.                this.menuBar.addNotify();
  132.                var2.setMenuBar(this.menuBar);
  133.             }
  134.          }
  135.  
  136.          ((Container)this).invalidate();
  137.       }
  138.    }
  139.  
  140.    public boolean isResizable() {
  141.       return this.resizable;
  142.    }
  143.  
  144.    public synchronized void setResizable(boolean var1) {
  145.       this.resizable = var1;
  146.       FramePeer var2 = (FramePeer)super.peer;
  147.       if (var2 != null) {
  148.          var2.setResizable(var1);
  149.       }
  150.  
  151.    }
  152.  
  153.    public synchronized void remove(MenuComponent var1) {
  154.       if (var1 == this.menuBar) {
  155.          FramePeer var2 = (FramePeer)super.peer;
  156.          if (var2 != null) {
  157.             this.mbManagement = true;
  158.             this.menuBar.removeNotify();
  159.             this.menuBar.parent = null;
  160.             var2.setMenuBar((MenuBar)null);
  161.          }
  162.  
  163.          this.menuBar = null;
  164.       } else {
  165.          super.remove(var1);
  166.       }
  167.    }
  168.  
  169.    public void dispose() {
  170.       Object var1 = Component.LOCK;
  171.       synchronized(var1){}
  172.  
  173.       try {
  174.          if (this.ownedWindows != null) {
  175.             int var3 = this.ownedWindows.size();
  176.             Window[] var4 = new Window[var3];
  177.             this.ownedWindows.copyInto(var4);
  178.  
  179.             for(int var5 = 0; var5 < var3; ++var5) {
  180.                var4[var5].dispose();
  181.             }
  182.          }
  183.  
  184.          if (this.menuBar != null) {
  185.             this.remove(this.menuBar);
  186.             this.menuBar = null;
  187.          }
  188.       } catch (Throwable var7) {
  189.          throw var7;
  190.       }
  191.  
  192.       super.dispose();
  193.    }
  194.  
  195.    void postProcessKeyEvent(KeyEvent var1) {
  196.       if (this.menuBar != null && this.menuBar.handleShortcut(var1)) {
  197.          ((InputEvent)var1).consume();
  198.       } else {
  199.          super.postProcessKeyEvent(var1);
  200.       }
  201.    }
  202.  
  203.    protected String paramString() {
  204.       String var1 = super.paramString();
  205.       if (this.resizable) {
  206.          var1 = var1 + ",resizable";
  207.       }
  208.  
  209.       if (this.title != null) {
  210.          var1 = var1 + ",title=" + this.title;
  211.       }
  212.  
  213.       return var1;
  214.    }
  215.  
  216.    public synchronized void setCursor(int var1) {
  217.       if (var1 >= 0 && var1 <= 13) {
  218.          ((Component)this).setCursor(Cursor.getPredefinedCursor(var1));
  219.       } else {
  220.          throw new IllegalArgumentException("illegal cursor type");
  221.       }
  222.    }
  223.  
  224.    public int getCursorType() {
  225.       return ((Component)this).getCursor().getType();
  226.    }
  227.  
  228.    private void writeObject(ObjectOutputStream var1) throws IOException {
  229.       var1.defaultWriteObject();
  230.    }
  231.  
  232.    private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
  233.       var1.defaultReadObject();
  234.       if (this.menuBar != null) {
  235.          this.menuBar.parent = this;
  236.       }
  237.  
  238.       if (this.ownedWindows != null) {
  239.          for(int var2 = 0; var2 < this.ownedWindows.size(); ++var2) {
  240.             Window var3 = (Window)this.ownedWindows.elementAt(var2);
  241.             var3.parent = this;
  242.          }
  243.       }
  244.  
  245.    }
  246. }
  247.