home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / browser / net_linx / java40.jar / sun / awt / motif / MFramePeer.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  4.2 KB  |  203 lines

  1. package sun.awt.motif;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Event;
  6. import java.awt.Font;
  7. import java.awt.Frame;
  8. import java.awt.Image;
  9. import java.awt.Insets;
  10. import java.awt.MenuBar;
  11. import java.awt.Rectangle;
  12. import java.awt.Window;
  13. import java.awt.peer.FramePeer;
  14. import java.util.Vector;
  15. import sun.awt.image.ImageRepresentation;
  16.  
  17. class MFramePeer extends MPanelPeer implements FramePeer {
  18.    Insets insets;
  19.    Vector windowList = new Vector();
  20.    static Vector allFrames = new Vector();
  21.  
  22.    native void create(MComponentPeer var1, Object var2);
  23.  
  24.    native void pSetTitle(String var1);
  25.  
  26.    native void pShow();
  27.  
  28.    native void pHide();
  29.  
  30.    native void pReshape(int var1, int var2, int var3, int var4);
  31.  
  32.    native void pDispose();
  33.  
  34.    native void pSetIconImage(ImageRepresentation var1);
  35.  
  36.    public native void setResizable(boolean var1);
  37.  
  38.    MFramePeer(Frame var1) {
  39.       super(var1, new Insets(Integer.getInteger("awt.frame.topInset", 25), Integer.getInteger("awt.frame.leftInset", 5), Integer.getInteger("awt.frame.bottomInset", 5), Integer.getInteger("awt.frame.rightInset", 5)));
  40.       allFrames.addElement(this);
  41.       if (var1.getTitle() != null) {
  42.          this.pSetTitle(var1.getTitle());
  43.       }
  44.  
  45.       Font var2 = ((Component)var1).getFont();
  46.       if (var2 == null) {
  47.          var2 = new Font("Dialog", 0, 12);
  48.          ((Component)var1).setFont(var2);
  49.          ((MComponentPeer)this).setFont(var2);
  50.       }
  51.  
  52.       Color var3 = ((Component)var1).getBackground();
  53.       if (var3 == null) {
  54.          ((Component)var1).setBackground(Color.lightGray);
  55.          ((MComponentPeer)this).setBackground(Color.lightGray);
  56.       }
  57.  
  58.       var3 = ((Component)var1).getForeground();
  59.       if (var3 == null) {
  60.          ((Component)var1).setForeground(Color.black);
  61.          ((MComponentPeer)this).setForeground(Color.black);
  62.       }
  63.  
  64.       Image var4 = var1.getIconImage();
  65.       if (var4 != null) {
  66.          this.setIconImage(var4);
  67.       }
  68.  
  69.       if (var1.getCursorType() != 0) {
  70.          this.setCursor(var1.getCursorType());
  71.       }
  72.  
  73.       this.setResizable(var1.isResizable());
  74.    }
  75.  
  76.    public void setTitle(String var1) {
  77.       this.pSetTitle(var1);
  78.    }
  79.  
  80.    public void dispose() {
  81.       Vector var1 = this.windowList;
  82.       synchronized(var1){}
  83.  
  84.       try {
  85.          while(!this.windowList.isEmpty()) {
  86.             Window var3 = (Window)this.windowList.firstElement();
  87.             var3.dispose();
  88.          }
  89.       } catch (Throwable var5) {
  90.          throw var5;
  91.       }
  92.  
  93.       allFrames.removeElement(this);
  94.       super.dispose();
  95.    }
  96.  
  97.    public void setIconImage(Image var1) {
  98.       ImageRepresentation var2 = ((X11Image)var1).getImageRep(-1, -1);
  99.       var2.reconstruct(32);
  100.       this.pSetIconImage(var2);
  101.    }
  102.  
  103.    public void setMenuBar(MenuBar var1) {
  104.       this.pSetMenuBar(var1);
  105.       if (super.target.isVisible()) {
  106.          Rectangle var2 = super.target.bounds();
  107.          this.pReshape(var2.x, var2.y, var2.width, var2.height);
  108.          super.target.invalidate();
  109.          super.target.validate();
  110.       }
  111.  
  112.    }
  113.  
  114.    native void pSetMenuBar(MenuBar var1);
  115.  
  116.    public void handleQuit() {
  117.       if (super.applet != null) {
  118.          XEvent var1 = new XEvent(new Event(super.target, 201, (Object)null), this);
  119.          super.applet.sendEvent(var1);
  120.       } else {
  121.          super.target.postEvent(new Event(super.target, 201, (Object)null));
  122.       }
  123.    }
  124.  
  125.    public void handleIconify() {
  126.       if (super.applet != null) {
  127.          XEvent var1 = new XEvent(new Event(super.target, 203, (Object)null), this);
  128.          super.applet.sendEvent(var1);
  129.       } else {
  130.          super.target.postEvent(new Event(super.target, 203, (Object)null));
  131.       }
  132.    }
  133.  
  134.    public void handleDeiconify() {
  135.       if (super.applet != null) {
  136.          XEvent var1 = new XEvent(new Event(super.target, 204, (Object)null), this);
  137.          super.applet.sendEvent(var1);
  138.       } else {
  139.          super.target.postEvent(new Event(super.target, 204, (Object)null));
  140.       }
  141.    }
  142.  
  143.    public void toFront() {
  144.       this.pShow();
  145.    }
  146.  
  147.    public native void toBack();
  148.  
  149.    public synchronized void handleMoved(int var1, int var2) {
  150.       if (super.applet != null) {
  151.          XEvent var3 = new XEvent(new Event(super.target, 0L, 205, var1, var2, 0, 0), this);
  152.          super.applet.sendEvent(var3);
  153.       } else {
  154.          super.target.postEvent(new Event(super.target, 0L, 205, var1, var2, 0, 0));
  155.       }
  156.    }
  157.  
  158.    public synchronized void handleResize(int var1, int var2) {
  159.       if (super.applet != null) {
  160.          XEvent var3 = new XEvent(new Event(super.target, 207, (Object)null), this);
  161.          super.applet.sendEvent(var3);
  162.       } else {
  163.          super.target.invalidate();
  164.          super.target.validate();
  165.          super.target.repaint();
  166.       }
  167.    }
  168.  
  169.    public Insets insets() {
  170.       return this.insets;
  171.    }
  172.  
  173.    public native void setCursor(int var1);
  174.  
  175.    void addWindow(Window var1) {
  176.       Vector var2 = this.windowList;
  177.       synchronized(var2){}
  178.  
  179.       try {
  180.          if (var1 != null) {
  181.             this.windowList.addElement(var1);
  182.          }
  183.       } catch (Throwable var4) {
  184.          throw var4;
  185.       }
  186.  
  187.    }
  188.  
  189.    void removeWindow(Window var1) {
  190.       Vector var2 = this.windowList;
  191.       synchronized(var2){}
  192.  
  193.       try {
  194.          if (var1 != null) {
  195.             this.windowList.removeElement(var1);
  196.          }
  197.       } catch (Throwable var4) {
  198.          throw var4;
  199.       }
  200.  
  201.    }
  202. }
  203.