home *** CD-ROM | disk | FTP | other *** search
- package javax.swing;
-
- import java.applet.Applet;
- import java.awt.BorderLayout;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Graphics;
- import java.awt.Panel;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.Window;
- import java.awt.event.KeyEvent;
- import java.io.Serializable;
-
- public class DefaultPopupFactory$PanelPopup extends Panel implements Popup, Serializable {
- int desiredLocationX;
- int desiredLocationY;
- JRootPane rootPane;
- // $FF: synthetic field
- private final DefaultPopupFactory this$0;
-
- public DefaultPopupFactory$PanelPopup(DefaultPopupFactory var1) {
- this.this$0 = var1;
- ((Container)this).setLayout(new BorderLayout());
- this.rootPane = new JRootPane();
- ((Container)this).add(this.rootPane, "Center");
- }
-
- protected void processKeyEvent(KeyEvent var1) {
- MenuSelectionManager.defaultManager().processKeyEvent(var1);
- }
-
- public int getWidth() {
- return ((Component)this).getBounds().width;
- }
-
- public int getHeight() {
- return ((Component)this).getBounds().height;
- }
-
- public Component getComponent() {
- return this;
- }
-
- public void addComponent(Component var1, Object var2) {
- this.rootPane.getContentPane().add(var1, var2);
- }
-
- public void removeComponent(Component var1) {
- this.rootPane.getContentPane().remove(var1);
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
-
- public void paint(Graphics var1) {
- super.paint(var1);
- }
-
- public void pack() {
- ((Component)this).setSize(((Container)this).getPreferredSize());
- }
-
- public void show(Component var1) {
- Container var2 = null;
- if (var1 != null) {
- var2 = var1.getParent();
- }
-
- while(!(var2 instanceof Window) && !(var2 instanceof Applet) && var2 != null) {
- var2 = ((Component)var2).getParent();
- }
-
- if (var2 instanceof RootPaneContainer) {
- JLayeredPane var4 = ((RootPaneContainer)var2).getLayeredPane();
- Point var3 = this.convertScreenLocationToParent(var4, this.desiredLocationX, this.desiredLocationY);
- ((Component)this).setLocation(var3.x, var3.y);
- ((JLayeredPane)var4).add(this, JLayeredPane.POPUP_LAYER, 0);
- } else {
- Point var5 = this.convertScreenLocationToParent(var2, this.desiredLocationX, this.desiredLocationY);
- ((Component)this).setLocation(var5.x, var5.y);
- 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;
- }
-
- }
- }
-