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$JPanelPopup.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  3.3 KB  |  162 lines

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