home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / DefaultPopupFactory$PanelPopup.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  3.4 KB  |  164 lines

  1. package javax.swing;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.BorderLayout;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Graphics;
  8. import java.awt.Panel;
  9. import java.awt.Point;
  10. import java.awt.Rectangle;
  11. import java.awt.Window;
  12. import java.awt.event.KeyEvent;
  13. import java.io.Serializable;
  14.  
  15. public class DefaultPopupFactory$PanelPopup extends Panel implements Popup, Serializable {
  16.    int desiredLocationX;
  17.    int desiredLocationY;
  18.    JRootPane rootPane;
  19.    // $FF: synthetic field
  20.    private final DefaultPopupFactory this$0;
  21.  
  22.    public DefaultPopupFactory$PanelPopup(DefaultPopupFactory var1) {
  23.       this.this$0 = var1;
  24.       ((Container)this).setLayout(new BorderLayout());
  25.       this.rootPane = new JRootPane();
  26.       ((Container)this).add(this.rootPane, "Center");
  27.    }
  28.  
  29.    protected void processKeyEvent(KeyEvent var1) {
  30.       MenuSelectionManager.defaultManager().processKeyEvent(var1);
  31.    }
  32.  
  33.    public int getWidth() {
  34.       return ((Component)this).getBounds().width;
  35.    }
  36.  
  37.    public int getHeight() {
  38.       return ((Component)this).getBounds().height;
  39.    }
  40.  
  41.    public Component getComponent() {
  42.       return this;
  43.    }
  44.  
  45.    public void addComponent(Component var1, Object var2) {
  46.       this.rootPane.getContentPane().add(var1, var2);
  47.    }
  48.  
  49.    public void removeComponent(Component var1) {
  50.       this.rootPane.getContentPane().remove(var1);
  51.    }
  52.  
  53.    public void update(Graphics var1) {
  54.       this.paint(var1);
  55.    }
  56.  
  57.    public void paint(Graphics var1) {
  58.       super.paint(var1);
  59.    }
  60.  
  61.    public void pack() {
  62.       ((Component)this).setSize(((Container)this).getPreferredSize());
  63.    }
  64.  
  65.    public void show(Component var1) {
  66.       Container var2 = null;
  67.       if (var1 != null) {
  68.          var2 = var1.getParent();
  69.       }
  70.  
  71.       while(!(var2 instanceof Window) && !(var2 instanceof Applet) && var2 != null) {
  72.          var2 = ((Component)var2).getParent();
  73.       }
  74.  
  75.       if (var2 instanceof RootPaneContainer) {
  76.          JLayeredPane var4 = ((RootPaneContainer)var2).getLayeredPane();
  77.          Point var3 = this.convertScreenLocationToParent(var4, this.desiredLocationX, this.desiredLocationY);
  78.          ((Component)this).setLocation(var3.x, var3.y);
  79.          ((JLayeredPane)var4).add(this, JLayeredPane.POPUP_LAYER, 0);
  80.       } else {
  81.          Point var5 = this.convertScreenLocationToParent(var2, this.desiredLocationX, this.desiredLocationY);
  82.          ((Component)this).setLocation(var5.x, var5.y);
  83.          var2.add(this);
  84.       }
  85.  
  86.    }
  87.  
  88.    public void hide() {
  89.       Container var1 = ((Component)this).getParent();
  90.       Rectangle var2 = ((Component)this).getBounds();
  91.       if (var1 != null) {
  92.          var1.remove(this);
  93.       }
  94.  
  95.       ((Component)var1).repaint(var2.x, var2.y, var2.width, var2.height);
  96.    }
  97.  
  98.    public Rectangle getBoundsOnScreen() {
  99.       Container var1 = ((Component)this).getParent();
  100.       if (var1 != null) {
  101.          Rectangle var2 = ((Component)this).getBounds();
  102.          Point var3 = this.convertParentLocationToScreen(var1, var2.x, var2.y);
  103.          var2.x = var3.x;
  104.          var2.y = var3.y;
  105.          return var2;
  106.       } else {
  107.          throw new Error("getBoundsOnScreen called on an invisible popup");
  108.       }
  109.    }
  110.  
  111.    Point convertParentLocationToScreen(Container var1, int var2, int var3) {
  112.       Window var4 = null;
  113.  
  114.       for(Object var6 = this; var6 != null; var6 = ((Component)var6).getParent()) {
  115.          if (var6 instanceof Window) {
  116.             var4 = (Window)var6;
  117.             break;
  118.          }
  119.       }
  120.  
  121.       if (var4 != null) {
  122.          Rectangle var5 = ((Component)var4).getBounds();
  123.          Point var7 = new Point(var2, var3);
  124.          var7 = SwingUtilities.convertPoint(var1, var7, (Component)null);
  125.          var7.x += var5.x;
  126.          var7.y += var5.y;
  127.          return var7;
  128.       } else {
  129.          throw new Error("convertParentLocationToScreen: no window ancestor found");
  130.       }
  131.    }
  132.  
  133.    Point convertScreenLocationToParent(Container var1, int var2, int var3) {
  134.       Window var4 = null;
  135.  
  136.       for(Container var6 = var1; var6 != null; var6 = ((Component)var6).getParent()) {
  137.          if (var6 instanceof Window) {
  138.             var4 = (Window)var6;
  139.             break;
  140.          }
  141.       }
  142.  
  143.       if (var4 != null) {
  144.          Point var7 = new Point(var2, var3);
  145.          SwingUtilities.convertPointFromScreen(var7, var1);
  146.          return var7;
  147.       } else {
  148.          throw new Error("convertScreenLocationToParent: no window ancestor found");
  149.       }
  150.    }
  151.  
  152.    public void setLocationOnScreen(int var1, int var2) {
  153.       Container var3 = ((Component)this).getParent();
  154.       if (var3 != null) {
  155.          Point var4 = this.convertScreenLocationToParent(var3, var1, var2);
  156.          ((Component)this).setLocation(var4.x, var4.y);
  157.       } else {
  158.          this.desiredLocationX = var1;
  159.          this.desiredLocationY = var2;
  160.       }
  161.  
  162.    }
  163. }
  164.