home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / java / awt / Frame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-07-08  |  5.3 KB  |  233 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.    Vector ownedWindows;
  31.    private static final String base = "frame";
  32.    private static int nameCounter;
  33.    private static final long serialVersionUID = 2673458971256075116L;
  34.    private int frameSerializedDataVersion;
  35.  
  36.    public Frame() {
  37.       this("");
  38.    }
  39.  
  40.    public Frame(String var1) {
  41.       this.title = "Untitled";
  42.       this.resizable = true;
  43.       this.frameSerializedDataVersion = 1;
  44.       super.name = "frame" + nameCounter++;
  45.       this.title = var1;
  46.       super.visible = false;
  47.       ((Container)this).setLayout(new BorderLayout());
  48.    }
  49.  
  50.    Window addOwnedWindow(Window var1) {
  51.       if (var1 != null) {
  52.          if (this.ownedWindows == null) {
  53.             this.ownedWindows = new Vector();
  54.          }
  55.  
  56.          this.ownedWindows.addElement(var1);
  57.       }
  58.  
  59.       return var1;
  60.    }
  61.  
  62.    void removeOwnedWindow(Window var1) {
  63.       if (var1 != null && this.ownedWindows != null) {
  64.          this.ownedWindows.removeElement(var1);
  65.       }
  66.  
  67.    }
  68.  
  69.    public void addNotify() {
  70.       super.peer = ((Window)this).getToolkit().createFrame(this);
  71.       MenuBar var1 = this.menuBar;
  72.       if (var1 != null) {
  73.          var1.addNotify();
  74.          ((FramePeer)super.peer).setMenuBar(var1);
  75.       }
  76.  
  77.       super.addNotify();
  78.    }
  79.  
  80.    public String getTitle() {
  81.       return this.title;
  82.    }
  83.  
  84.    public synchronized void setTitle(String var1) {
  85.       this.title = var1;
  86.       FramePeer var2 = (FramePeer)super.peer;
  87.       if (var2 != null) {
  88.          var2.setTitle(var1);
  89.       }
  90.  
  91.    }
  92.  
  93.    public Image getIconImage() {
  94.       return this.icon;
  95.    }
  96.  
  97.    public synchronized void setIconImage(Image var1) {
  98.       this.icon = var1;
  99.       FramePeer var2 = (FramePeer)super.peer;
  100.       if (var2 != null) {
  101.          var2.setIconImage(var1);
  102.       }
  103.  
  104.    }
  105.  
  106.    public MenuBar getMenuBar() {
  107.       return this.menuBar;
  108.    }
  109.  
  110.    public synchronized void setMenuBar(MenuBar var1) {
  111.       if (this.menuBar != var1) {
  112.          if (var1 != null && var1.parent != null) {
  113.             var1.parent.remove(var1);
  114.          }
  115.  
  116.          if (this.menuBar != null) {
  117.             this.remove(this.menuBar);
  118.          }
  119.  
  120.          this.menuBar = var1;
  121.          if (this.menuBar != null) {
  122.             this.menuBar.parent = this;
  123.             FramePeer var2 = (FramePeer)super.peer;
  124.             if (var2 != null) {
  125.                this.menuBar.addNotify();
  126.                var2.setMenuBar(this.menuBar);
  127.             }
  128.          }
  129.  
  130.          ((Container)this).invalidate();
  131.       }
  132.    }
  133.  
  134.    public boolean isResizable() {
  135.       return this.resizable;
  136.    }
  137.  
  138.    public synchronized void setResizable(boolean var1) {
  139.       this.resizable = var1;
  140.       FramePeer var2 = (FramePeer)super.peer;
  141.       if (var2 != null) {
  142.          var2.setResizable(var1);
  143.       }
  144.  
  145.    }
  146.  
  147.    public synchronized void remove(MenuComponent var1) {
  148.       if (var1 == this.menuBar) {
  149.          FramePeer var2 = (FramePeer)super.peer;
  150.          if (var2 != null) {
  151.             this.menuBar.removeNotify();
  152.             this.menuBar.parent = null;
  153.             var2.setMenuBar((MenuBar)null);
  154.          }
  155.  
  156.          this.menuBar = null;
  157.       } else {
  158.          super.remove(var1);
  159.       }
  160.    }
  161.  
  162.    public synchronized void dispose() {
  163.       if (this.ownedWindows != null) {
  164.          int var1 = this.ownedWindows.size();
  165.          Window[] var2 = new Window[var1];
  166.          this.ownedWindows.copyInto(var2);
  167.  
  168.          for(int var3 = 0; var3 < var1; ++var3) {
  169.             var2[var3].dispose();
  170.          }
  171.       }
  172.  
  173.       if (this.menuBar != null) {
  174.          this.remove(this.menuBar);
  175.          this.menuBar = null;
  176.       }
  177.  
  178.       super.dispose();
  179.    }
  180.  
  181.    void postProcessKeyEvent(KeyEvent var1) {
  182.       if (this.menuBar != null && this.menuBar.handleShortcut(var1)) {
  183.          ((InputEvent)var1).consume();
  184.       } else {
  185.          super.postProcessKeyEvent(var1);
  186.       }
  187.    }
  188.  
  189.    protected String paramString() {
  190.       String var1 = super.paramString();
  191.       if (this.resizable) {
  192.          var1 = var1 + ",resizable";
  193.       }
  194.  
  195.       if (this.title != null) {
  196.          var1 = var1 + ",title=" + this.title;
  197.       }
  198.  
  199.       return var1;
  200.    }
  201.  
  202.    public synchronized void setCursor(int var1) {
  203.       if (var1 >= 0 && var1 <= 13) {
  204.          ((Component)this).setCursor(Cursor.getPredefinedCursor(var1));
  205.       } else {
  206.          throw new IllegalArgumentException("illegal cursor type");
  207.       }
  208.    }
  209.  
  210.    public int getCursorType() {
  211.       return ((Component)this).getCursor().getType();
  212.    }
  213.  
  214.    private void writeObject(ObjectOutputStream var1) throws IOException {
  215.       var1.defaultWriteObject();
  216.    }
  217.  
  218.    private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
  219.       var1.defaultReadObject();
  220.       if (this.menuBar != null) {
  221.          this.menuBar.parent = this;
  222.       }
  223.  
  224.       if (this.ownedWindows != null) {
  225.          for(int var2 = 0; var2 < this.ownedWindows.size(); ++var2) {
  226.             Window var3 = (Window)this.ownedWindows.elementAt(var2);
  227.             var3.parent = this;
  228.          }
  229.       }
  230.  
  231.    }
  232. }
  233.