home *** CD-ROM | disk | FTP | other *** search
- package javax.swing;
-
- import java.awt.BorderLayout;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.Window;
- import java.awt.event.KeyEvent;
- import java.io.Serializable;
-
- public class DefaultPopupFactory$JPanelPopup extends JPanel implements Popup, Serializable {
- int desiredLocationX;
- int desiredLocationY;
- // $FF: synthetic field
- private final DefaultPopupFactory this$0;
-
- public DefaultPopupFactory$JPanelPopup(DefaultPopupFactory var1) {
- this.this$0 = var1;
- ((Container)this).setLayout(new BorderLayout());
- ((JComponent)this).setDoubleBuffered(true);
- ((JComponent)this).setOpaque(true);
- }
-
- protected void processKeyEvent(KeyEvent var1) {
- MenuSelectionManager.defaultManager().processKeyEvent(var1);
- }
-
- public Component getComponent() {
- return this;
- }
-
- public void addComponent(Component var1, Object var2) {
- ((Container)this).add(var1, var2);
- }
-
- public void removeComponent(Component var1) {
- ((Container)this).remove(var1);
- }
-
- public void update(Graphics var1) {
- ((JComponent)this).paint(var1);
- }
-
- public void pack() {
- ((Component)this).setSize(((JComponent)this).getPreferredSize());
- }
-
- public void show(Component var1) {
- Object var2 = null;
- if (var1 != null) {
- var2 = var1.getParent();
- }
-
- Object var3 = null;
-
- for(Object var4 = var2; var4 != null; var4 = ((Component)var4).getParent()) {
- if (var4 instanceof JRootPane) {
- if (!(((Component)var4).getParent() instanceof JInternalFrame)) {
- var2 = ((JRootPane)var4).getLayeredPane();
-
- for(var8 = ((Component)var2).getParent(); var8 != null && !(var8 instanceof Window); var8 = ((Component)var8).getParent()) {
- }
-
- Window var6 = (Window)var8;
- break;
- }
- } else if (var4 instanceof Window) {
- var2 = var4;
- Window var7 = (Window)var4;
- break;
- }
- }
-
- Point var5 = this.convertScreenLocationToParent((Container)var2, this.desiredLocationX, this.desiredLocationY);
- ((Component)this).setLocation(var5.x, var5.y);
- if (var2 instanceof JLayeredPane) {
- ((JLayeredPane)var2).add(this, JLayeredPane.POPUP_LAYER, 0);
- } else {
- ((Container)var2).add(this);
- }
-
- }
-
- public void hide() {
- Container var1 = ((Component)this).getParent();
- Rectangle var2 = ((Component)this).getBounds();
- if (var1 != null) {
- var1.remove(this);
- }
-
- ((Component)var1).repaint(var2.x, var2.y, var2.width, var2.height);
- }
-
- public Rectangle getBoundsOnScreen() {
- Container var1 = ((Component)this).getParent();
- if (var1 != null) {
- Rectangle var2 = ((Component)this).getBounds();
- Point var3 = this.convertParentLocationToScreen(var1, var2.x, var2.y);
- var2.x = var3.x;
- var2.y = var3.y;
- return var2;
- } else {
- throw new Error("getBoundsOnScreen called on an invisible popup");
- }
- }
-
- Point convertParentLocationToScreen(Container var1, int var2, int var3) {
- Window var4 = null;
-
- for(Object var6 = this; var6 != null; var6 = ((Component)var6).getParent()) {
- if (var6 instanceof Window) {
- var4 = (Window)var6;
- break;
- }
- }
-
- if (var4 != null) {
- Rectangle var5 = ((Component)var4).getBounds();
- Point var7 = new Point(var2, var3);
- var7 = SwingUtilities.convertPoint(var1, var7, (Component)null);
- var7.x += var5.x;
- var7.y += var5.y;
- return var7;
- } else {
- throw new Error("convertParentLocationToScreen: no window ancestor found");
- }
- }
-
- Point convertScreenLocationToParent(Container var1, int var2, int var3) {
- Window var4 = null;
-
- for(Container var6 = var1; var6 != null; var6 = ((Component)var6).getParent()) {
- if (var6 instanceof Window) {
- var4 = (Window)var6;
- break;
- }
- }
-
- if (var4 != null) {
- Point var7 = new Point(var2, var3);
- SwingUtilities.convertPointFromScreen(var7, var1);
- return var7;
- } else {
- throw new Error("convertScreenLocationToParent: no window ancestor found");
- }
- }
-
- public void setLocationOnScreen(int var1, int var2) {
- Container var3 = ((Component)this).getParent();
- if (var3 != null) {
- Point var4 = this.convertScreenLocationToParent(var3, var1, var2);
- ((Component)this).setLocation(var4.x, var4.y);
- } else {
- this.desiredLocationX = var1;
- this.desiredLocationY = var2;
- }
-
- }
- }
-