home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 144 / DPCS0200.iso / Internet / Supanet / system / swing.jar / javax / swing / JPopupMenu.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-05  |  18.4 KB  |  874 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dialog;
  6. import java.awt.Dimension;
  7. import java.awt.Frame;
  8. import java.awt.Graphics;
  9. import java.awt.Insets;
  10. import java.awt.Point;
  11. import java.awt.Rectangle;
  12. import java.awt.Window;
  13. import java.awt.event.KeyEvent;
  14. import java.awt.event.MouseEvent;
  15. import java.beans.PropertyChangeListener;
  16. import java.io.IOException;
  17. import java.io.ObjectInputStream;
  18. import java.io.ObjectOutputStream;
  19. import java.io.Serializable;
  20. import java.util.Hashtable;
  21. import java.util.Vector;
  22. import javax.accessibility.Accessible;
  23. import javax.accessibility.AccessibleContext;
  24. import javax.accessibility.AccessibleState;
  25. import javax.swing.event.PopupMenuEvent;
  26. import javax.swing.event.PopupMenuListener;
  27. import javax.swing.plaf.PopupMenuUI;
  28.  
  29. public class JPopupMenu extends JComponent implements Accessible, MenuElement {
  30.    private static final String uiClassID = "PopupMenuUI";
  31.    transient Component invoker;
  32.    transient Popup popup;
  33.    transient Frame frame;
  34.    private String label;
  35.    private boolean paintBorder;
  36.    private Insets margin;
  37.    private int desiredLocationX;
  38.    private int desiredLocationY;
  39.    private int lastPopupType;
  40.    private static final Object heavyPopupCacheKey = new StringBuffer("JPopupMenu.heavyPopupCache");
  41.    private static final Object lightPopupCacheKey = new StringBuffer("JPopupMenu.lightPopupCache");
  42.    private static final Object mediumPopupCacheKey = new StringBuffer("JPopupMenu.mediumPopupCache");
  43.    private static final Object defaultLWPopupEnabledKey = new StringBuffer("JPopupMenu.defaultLWPopupEnabledKey");
  44.    private static final int MAX_CACHE_SIZE = 5;
  45.    private boolean lightWeightPopupEnabled;
  46.    private static final int LIGHT_WEIGHT_POPUP = 0;
  47.    private static final int MEDIUM_WEIGHT_POPUP = 1;
  48.    private static final int HEAVY_WEIGHT_POPUP = 2;
  49.    private SingleSelectionModel selectionModel;
  50.    private static Hashtable listenerRegistry = null;
  51.    // $FF: synthetic field
  52.    static Class class$javax$swing$event$PopupMenuListener;
  53.  
  54.    public JPopupMenu() {
  55.       this((String)null);
  56.    }
  57.  
  58.    public JPopupMenu(String var1) {
  59.       this.label = null;
  60.       this.paintBorder = true;
  61.       this.margin = null;
  62.       this.lastPopupType = 0;
  63.       this.lightWeightPopupEnabled = true;
  64.       this.label = var1;
  65.       this.lightWeightPopupEnabled = getDefaultLightWeightPopupEnabled();
  66.       this.setSelectionModel(new DefaultSingleSelectionModel());
  67.       ((Component)this).addMouseListener(new 2());
  68.       this.updateUI();
  69.    }
  70.  
  71.    // $FF: synthetic method
  72.    static Hashtable access$0() {
  73.       return getHeavyPopupCache();
  74.    }
  75.  
  76.    public JMenuItem add(String var1) {
  77.       return this.add(new JMenuItem(var1));
  78.    }
  79.  
  80.    public JMenuItem add(Action var1) {
  81.       JMenuItem var2 = new JMenuItem((String)var1.getValue("Name"), (Icon)var1.getValue("SmallIcon"));
  82.       ((AbstractButton)var2).setHorizontalTextPosition(4);
  83.       ((AbstractButton)var2).setVerticalTextPosition(0);
  84.       var2.setEnabled(var1.isEnabled());
  85.       ((AbstractButton)var2).addActionListener(var1);
  86.       this.add(var2);
  87.       PropertyChangeListener var3 = this.createActionChangeListener(var2);
  88.       if (listenerRegistry == null) {
  89.          listenerRegistry = new Hashtable();
  90.       }
  91.  
  92.       listenerRegistry.put(var2, var1);
  93.       listenerRegistry.put(var1, var3);
  94.       var1.addPropertyChangeListener(var3);
  95.       return var2;
  96.    }
  97.  
  98.    public JMenuItem add(JMenuItem var1) {
  99.       super.add(var1);
  100.       return var1;
  101.    }
  102.  
  103.    public void addPopupMenuListener(PopupMenuListener var1) {
  104.       super.listenerList.add(class$javax$swing$event$PopupMenuListener != null ? class$javax$swing$event$PopupMenuListener : (class$javax$swing$event$PopupMenuListener = class$("javax.swing.event.PopupMenuListener")), var1);
  105.    }
  106.  
  107.    public void addSeparator() {
  108.       ((Container)this).add(new Separator());
  109.    }
  110.  
  111.    boolean alwaysOnTop() {
  112.       return true;
  113.    }
  114.  
  115.    private boolean ancestorIsModalDialog(Component var1) {
  116.       Object var2 = null;
  117.       if (var1 != null) {
  118.          for(Container var3 = var1.getParent(); var3 != null; var3 = ((Component)var3).getParent()) {
  119.             if (var3 instanceof Dialog && ((Dialog)var3).isModal()) {
  120.                return true;
  121.             }
  122.          }
  123.       }
  124.  
  125.       return false;
  126.    }
  127.  
  128.    // $FF: synthetic method
  129.    static Class class$(String var0) {
  130.       try {
  131.          return Class.forName(var0);
  132.       } catch (ClassNotFoundException var2) {
  133.          throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  134.       }
  135.    }
  136.  
  137.    protected PropertyChangeListener createActionChangeListener(JMenuItem var1) {
  138.       return new ActionChangedListener(this, var1);
  139.    }
  140.  
  141.    private Popup createHeavyWeightPopup() {
  142.       Frame var1 = getFrame(this.invoker);
  143.       if (var1 != null) {
  144.          this.popup = getRecycledHeavyPopup(var1);
  145.       } else {
  146.          var1 = new Frame();
  147.       }
  148.  
  149.       if (this.popup == null) {
  150.          this.popup = new WindowPopup(this, var1);
  151.       }
  152.  
  153.       return this.popup;
  154.    }
  155.  
  156.    private Popup createLightWeightPopup() {
  157.       Object var1 = getRecycledLightPopup();
  158.       if (var1 == null) {
  159.          var1 = new JPanelPopup(this);
  160.       }
  161.  
  162.       return (Popup)var1;
  163.    }
  164.  
  165.    private Popup createMediumWeightPopup() {
  166.       Object var1 = getRecycledMediumPopup();
  167.       if (var1 == null) {
  168.          var1 = new PanelPopup(this);
  169.       }
  170.  
  171.       return (Popup)var1;
  172.    }
  173.  
  174.    protected void firePopupMenuCanceled() {
  175.       Object[] var1 = super.listenerList.getListenerList();
  176.       PopupMenuEvent var2 = null;
  177.  
  178.       for(int var3 = var1.length - 2; var3 >= 0; var3 -= 2) {
  179.          if (var1[var3] == (class$javax$swing$event$PopupMenuListener != null ? class$javax$swing$event$PopupMenuListener : (class$javax$swing$event$PopupMenuListener = class$("javax.swing.event.PopupMenuListener")))) {
  180.             if (var2 == null) {
  181.                var2 = new PopupMenuEvent(this);
  182.             }
  183.  
  184.             ((PopupMenuListener)var1[var3 + 1]).popupMenuCanceled(var2);
  185.          }
  186.       }
  187.  
  188.    }
  189.  
  190.    protected void firePopupMenuWillBecomeInvisible() {
  191.       Object[] var1 = super.listenerList.getListenerList();
  192.       PopupMenuEvent var2 = null;
  193.  
  194.       for(int var3 = var1.length - 2; var3 >= 0; var3 -= 2) {
  195.          if (var1[var3] == (class$javax$swing$event$PopupMenuListener != null ? class$javax$swing$event$PopupMenuListener : (class$javax$swing$event$PopupMenuListener = class$("javax.swing.event.PopupMenuListener")))) {
  196.             if (var2 == null) {
  197.                var2 = new PopupMenuEvent(this);
  198.             }
  199.  
  200.             ((PopupMenuListener)var1[var3 + 1]).popupMenuWillBecomeInvisible(var2);
  201.          }
  202.       }
  203.  
  204.    }
  205.  
  206.    protected void firePopupMenuWillBecomeVisible() {
  207.       Object[] var1 = super.listenerList.getListenerList();
  208.       PopupMenuEvent var2 = null;
  209.  
  210.       for(int var3 = var1.length - 2; var3 >= 0; var3 -= 2) {
  211.          if (var1[var3] == (class$javax$swing$event$PopupMenuListener != null ? class$javax$swing$event$PopupMenuListener : (class$javax$swing$event$PopupMenuListener = class$("javax.swing.event.PopupMenuListener")))) {
  212.             if (var2 == null) {
  213.                var2 = new PopupMenuEvent(this);
  214.             }
  215.  
  216.             ((PopupMenuListener)var1[var3 + 1]).popupMenuWillBecomeVisible(var2);
  217.          }
  218.       }
  219.  
  220.    }
  221.  
  222.    public AccessibleContext getAccessibleContext() {
  223.       if (super.accessibleContext == null) {
  224.          super.accessibleContext = new AccessibleJPopupMenu(this);
  225.       }
  226.  
  227.       return super.accessibleContext;
  228.    }
  229.  
  230.    public Component getComponent() {
  231.       return this;
  232.    }
  233.  
  234.    public Component getComponentAtIndex(int var1) {
  235.       int var2 = ((Container)this).getComponentCount();
  236.       if (var1 <= var2) {
  237.          Component[] var3 = ((Container)this).getComponents();
  238.          return var3[var1];
  239.       } else {
  240.          return null;
  241.       }
  242.    }
  243.  
  244.    public int getComponentIndex(Component var1) {
  245.       int var2 = ((Container)this).getComponentCount();
  246.       Component[] var3 = ((Container)this).getComponents();
  247.  
  248.       for(int var4 = 0; var4 < var2; ++var4) {
  249.          Component var5 = var3[var4];
  250.          if (var5 == var1) {
  251.             return var4;
  252.          }
  253.       }
  254.  
  255.       return -1;
  256.    }
  257.  
  258.    public static boolean getDefaultLightWeightPopupEnabled() {
  259.       Boolean var0 = (Boolean)SwingUtilities.appContextGet(defaultLWPopupEnabledKey);
  260.       if (var0 == null) {
  261.          SwingUtilities.appContextPut(defaultLWPopupEnabledKey, Boolean.TRUE);
  262.          return true;
  263.       } else {
  264.          return var0;
  265.       }
  266.    }
  267.  
  268.    private static Frame getFrame(Component var0) {
  269.       Object var1;
  270.       for(var1 = var0; !(var1 instanceof Frame) && var1 != null; var1 = ((Component)var1).getParent()) {
  271.       }
  272.  
  273.       return (Frame)var1;
  274.    }
  275.  
  276.    private static Hashtable getHeavyPopupCache() {
  277.       Hashtable var0 = (Hashtable)SwingUtilities.appContextGet(heavyPopupCacheKey);
  278.       if (var0 == null) {
  279.          var0 = new Hashtable(2);
  280.          SwingUtilities.appContextPut(heavyPopupCacheKey, var0);
  281.       }
  282.  
  283.       return var0;
  284.    }
  285.  
  286.    public Component getInvoker() {
  287.       return this.invoker;
  288.    }
  289.  
  290.    public String getLabel() {
  291.       return this.label;
  292.    }
  293.  
  294.    private static Vector getLightPopupCache() {
  295.       Vector var0 = (Vector)SwingUtilities.appContextGet(lightPopupCacheKey);
  296.       if (var0 == null) {
  297.          var0 = new Vector();
  298.          SwingUtilities.appContextPut(lightPopupCacheKey, var0);
  299.       }
  300.  
  301.       return var0;
  302.    }
  303.  
  304.    public Insets getMargin() {
  305.       return this.margin == null ? new Insets(0, 0, 0, 0) : this.margin;
  306.    }
  307.  
  308.    private static Vector getMediumPopupCache() {
  309.       Vector var0 = (Vector)SwingUtilities.appContextGet(mediumPopupCacheKey);
  310.       if (var0 == null) {
  311.          var0 = new Vector();
  312.          SwingUtilities.appContextPut(mediumPopupCacheKey, var0);
  313.       }
  314.  
  315.       return var0;
  316.    }
  317.  
  318.    static synchronized Popup getRecycledHeavyPopup(Frame var0) {
  319.       Hashtable var2 = getHeavyPopupCache();
  320.       if (var2.containsKey(var0)) {
  321.          Vector var1 = (Vector)var2.get(var0);
  322.          if (var1.size() > 0) {
  323.             Popup var4 = (Popup)var1.elementAt(0);
  324.             var1.removeElementAt(0);
  325.             return var4;
  326.          } else {
  327.             return null;
  328.          }
  329.       } else {
  330.          return null;
  331.       }
  332.    }
  333.  
  334.    static synchronized Popup getRecycledLightPopup() {
  335.       Vector var0 = getLightPopupCache();
  336.       if (var0.size() > 0) {
  337.          Popup var2 = (Popup)var0.elementAt(0);
  338.          var0.removeElementAt(0);
  339.          return var2;
  340.       } else {
  341.          return null;
  342.       }
  343.    }
  344.  
  345.    static synchronized Popup getRecycledMediumPopup() {
  346.       Vector var0 = getMediumPopupCache();
  347.       if (var0.size() > 0) {
  348.          Popup var2 = (Popup)var0.elementAt(0);
  349.          var0.removeElementAt(0);
  350.          return var2;
  351.       } else {
  352.          return null;
  353.       }
  354.    }
  355.  
  356.    JPopupMenu getRootPopupMenu() {
  357.       JPopupMenu var1;
  358.       for(var1 = this; var1 != null && !var1.isPopupMenu() && var1.getInvoker() != null && var1.getInvoker().getParent() != null && var1.getInvoker().getParent() instanceof JPopupMenu; var1 = (JPopupMenu)var1.getInvoker().getParent()) {
  359.       }
  360.  
  361.       return var1;
  362.    }
  363.  
  364.    public SingleSelectionModel getSelectionModel() {
  365.       return this.selectionModel;
  366.    }
  367.  
  368.    public MenuElement[] getSubElements() {
  369.       Vector var2 = new Vector();
  370.       int var3 = ((Container)this).getComponentCount();
  371.  
  372.       for(int var4 = 0; var4 < var3; ++var4) {
  373.          Component var5 = ((Container)this).getComponent(var4);
  374.          if (var5 instanceof MenuElement) {
  375.             var2.addElement(var5);
  376.          }
  377.       }
  378.  
  379.       MenuElement[] var1 = new MenuElement[var2.size()];
  380.       int var7 = 0;
  381.  
  382.       for(int var6 = var2.size(); var7 < var6; ++var7) {
  383.          var1[var7] = (MenuElement)var2.elementAt(var7);
  384.       }
  385.  
  386.       return var1;
  387.    }
  388.  
  389.    public PopupMenuUI getUI() {
  390.       return (PopupMenuUI)super.ui;
  391.    }
  392.  
  393.    public String getUIClassID() {
  394.       return "PopupMenuUI";
  395.    }
  396.  
  397.    public void insert(Component var1, int var2) {
  398.       if (var2 < 0) {
  399.          throw new IllegalArgumentException("index less than zero.");
  400.       } else {
  401.          int var3 = ((Container)this).getComponentCount();
  402.          Vector var4 = new Vector();
  403.  
  404.          for(int var5 = var2; var5 < var3; ++var5) {
  405.             var4.addElement(((Container)this).getComponent(var2));
  406.             ((Container)this).remove(var2);
  407.          }
  408.  
  409.          ((Container)this).add(var1);
  410.  
  411.          for(int var6 = 0; var6 < var4.size(); ++var6) {
  412.             ((Container)this).add((Component)var4.elementAt(var6));
  413.          }
  414.  
  415.       }
  416.    }
  417.  
  418.    public void insert(Action var1, int var2) {
  419.       throw new Error("void insert(Action, int) {} not yet implemented");
  420.    }
  421.  
  422.    private boolean invokerInHeavyWeightPopup(Component var1) {
  423.       if (var1 != null) {
  424.          for(Container var2 = var1.getParent(); var2 != null; var2 = ((Component)var2).getParent()) {
  425.             if (var2 instanceof WindowPopup) {
  426.                return true;
  427.             }
  428.  
  429.             if (var2 instanceof PanelPopup || var2 instanceof JPanelPopup) {
  430.                break;
  431.             }
  432.          }
  433.       }
  434.  
  435.       return false;
  436.    }
  437.  
  438.    public boolean isBorderPainted() {
  439.       return this.paintBorder;
  440.    }
  441.  
  442.    public boolean isLightWeightPopupEnabled() {
  443.       return this.lightWeightPopupEnabled;
  444.    }
  445.  
  446.    private boolean isPopupMenu() {
  447.       return this.invoker != null && !(this.invoker instanceof JMenu);
  448.    }
  449.  
  450.    boolean isSubPopupMenu(JPopupMenu var1) {
  451.       int var2 = ((Container)this).getComponentCount();
  452.       Component[] var3 = ((Container)this).getComponents();
  453.  
  454.       for(int var4 = 0; var4 < var2; ++var4) {
  455.          Component var5 = var3[var4];
  456.          if (var5 instanceof JMenu) {
  457.             JMenu var6 = (JMenu)var5;
  458.             JPopupMenu var7 = var6.getPopupMenu();
  459.             if (var7 == var1) {
  460.                return true;
  461.             }
  462.  
  463.             if (var7.isSubPopupMenu(var1)) {
  464.                return true;
  465.             }
  466.          }
  467.       }
  468.  
  469.       return false;
  470.    }
  471.  
  472.    public boolean isVisible() {
  473.       return this.popup != null ? this.popup.isShowing() : false;
  474.    }
  475.  
  476.    public void menuSelectionChanged(boolean var1) {
  477.       if (this.invoker instanceof JMenu) {
  478.          JMenu var2 = (JMenu)this.invoker;
  479.          if (var1) {
  480.             var2.setPopupMenuVisible(true);
  481.          } else {
  482.             var2.setPopupMenuVisible(false);
  483.          }
  484.       }
  485.  
  486.       if (this.isPopupMenu() && !var1) {
  487.          this.setVisible(false);
  488.       }
  489.  
  490.    }
  491.  
  492.    public void pack() {
  493.       if (this.popup != null) {
  494.          this.popup.pack();
  495.       }
  496.  
  497.    }
  498.  
  499.    protected void paintBorder(Graphics var1) {
  500.       if (this.isBorderPainted()) {
  501.          super.paintBorder(var1);
  502.       }
  503.  
  504.    }
  505.  
  506.    protected String paramString() {
  507.       String var1 = this.label != null ? this.label : "";
  508.       String var2 = this.paintBorder ? "true" : "false";
  509.       String var3 = this.margin != null ? this.margin.toString() : "";
  510.       String var4;
  511.       if (this.lastPopupType == 0) {
  512.          var4 = "LIGHT_WEIGHT_POPUP";
  513.       } else if (this.lastPopupType == 1) {
  514.          var4 = "MEDIUM_WEIGHT_POPUP";
  515.       } else if (this.lastPopupType == 2) {
  516.          var4 = "HEAVY_WEIGHT_POPUP";
  517.       } else {
  518.          var4 = "";
  519.       }
  520.  
  521.       String var5 = this.lightWeightPopupEnabled ? "true" : "false";
  522.       return super.paramString() + ",desiredLocationX=" + this.desiredLocationX + ",desiredLocationY=" + this.desiredLocationY + ",label=" + var1 + ",lastPopupType=" + var4 + ",lightWeightPopupEnabled=" + var5 + ",margin=" + var3 + ",paintBorder=" + var2;
  523.    }
  524.  
  525.    private boolean popupFit(Rectangle var1) {
  526.       if (this.invoker != null) {
  527.          for(Container var2 = this.invoker.getParent(); var2 != null; var2 = ((Component)var2).getParent()) {
  528.             if (var2 instanceof JFrame || var2 instanceof JDialog || var2 instanceof JWindow) {
  529.                return SwingUtilities.isRectangleContainingRectangle(((Component)var2).getBounds(), var1);
  530.             }
  531.  
  532.             if (var2 instanceof JApplet) {
  533.                Rectangle var3 = ((Component)var2).getBounds();
  534.                Point var4 = ((Component)var2).getLocationOnScreen();
  535.                var3.x = var4.x;
  536.                var3.y = var4.y;
  537.                return SwingUtilities.isRectangleContainingRectangle(var3, var1);
  538.             }
  539.  
  540.             if (var2 instanceof Frame) {
  541.                return SwingUtilities.isRectangleContainingRectangle(((Component)var2).getBounds(), var1);
  542.             }
  543.          }
  544.       }
  545.  
  546.       return false;
  547.    }
  548.  
  549.    public void processKeyEvent(KeyEvent var1, MenuElement[] var2, MenuSelectionManager var3) {
  550.    }
  551.  
  552.    public void processMouseEvent(MouseEvent var1, MenuElement[] var2, MenuSelectionManager var3) {
  553.    }
  554.  
  555.    private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
  556.       var1.defaultReadObject();
  557.       Vector var2 = (Vector)var1.readObject();
  558.       int var3 = 0;
  559.       int var4 = var2.size();
  560.       if (var3 < var4 && var2.elementAt(var3).equals("invoker")) {
  561.          ++var3;
  562.          this.invoker = (Component)var2.elementAt(var3);
  563.          ++var3;
  564.       }
  565.  
  566.       if (var3 < var4 && var2.elementAt(var3).equals("popup")) {
  567.          ++var3;
  568.          this.popup = (Popup)var2.elementAt(var3);
  569.          ++var3;
  570.       }
  571.  
  572.       if (var3 < var4 && var2.elementAt(var3).equals("frame")) {
  573.          ++var3;
  574.          this.frame = (Frame)var2.elementAt(var3);
  575.          ++var3;
  576.       }
  577.  
  578.    }
  579.  
  580.    static synchronized void recycleHeavyPopup(Popup var0) {
  581.       Frame var2 = getFrame((Component)var0);
  582.       Hashtable var3 = getHeavyPopupCache();
  583.       Vector var1;
  584.       if (var3.containsKey(var2)) {
  585.          var1 = (Vector)var3.get(var2);
  586.       } else {
  587.          var1 = new Vector();
  588.          var3.put(var2, var1);
  589.          ((Window)var2).addWindowListener(new 1(var2));
  590.       }
  591.  
  592.       if (var1.size() < 5) {
  593.          var1.addElement(var0);
  594.       }
  595.  
  596.    }
  597.  
  598.    static synchronized void recycleLightPopup(Popup var0) {
  599.       Vector var1 = getLightPopupCache();
  600.       if (var1.size() < 5) {
  601.          var1.addElement(var0);
  602.       }
  603.  
  604.    }
  605.  
  606.    static synchronized void recycleMediumPopup(Popup var0) {
  607.       Vector var1 = getMediumPopupCache();
  608.       if (var1.size() < 5) {
  609.          var1.addElement(var0);
  610.       }
  611.  
  612.    }
  613.  
  614.    static void recyclePopup(Popup var0) {
  615.       if (var0 instanceof JPanelPopup) {
  616.          recycleLightPopup(var0);
  617.       } else if (var0 instanceof WindowPopup) {
  618.          recycleHeavyPopup(var0);
  619.       } else if (var0 instanceof PanelPopup) {
  620.          recycleMediumPopup(var0);
  621.       }
  622.  
  623.    }
  624.  
  625.    public void remove(Component var1) {
  626.       super.remove(var1);
  627.       if (var1 instanceof JMenuItem) {
  628.          JMenuItem var2 = (JMenuItem)var1;
  629.          if (listenerRegistry != null) {
  630.             ActionChangedListener var3 = (ActionChangedListener)listenerRegistry.remove(var2);
  631.             Action var4 = (Action)listenerRegistry.remove(var3);
  632.             ((AbstractButton)var2).removeActionListener(var4);
  633.             if (var3 != null) {
  634.                var3.setTarget((JMenuItem)null);
  635.             }
  636.  
  637.             if (var4 != null) {
  638.                var4.removePropertyChangeListener(var3);
  639.             }
  640.          }
  641.       }
  642.  
  643.    }
  644.  
  645.    public void removePopupMenuListener(PopupMenuListener var1) {
  646.       super.listenerList.remove(class$javax$swing$event$PopupMenuListener != null ? class$javax$swing$event$PopupMenuListener : (class$javax$swing$event$PopupMenuListener = class$("javax.swing.event.PopupMenuListener")), var1);
  647.    }
  648.  
  649.    private void replacePopup(int var1) {
  650.       this.popup.removeComponent(this);
  651.       recyclePopup(this.popup);
  652.       this.popup = null;
  653.       switch (var1) {
  654.          case 0:
  655.             this.popup = this.createLightWeightPopup();
  656.             break;
  657.          case 1:
  658.             this.popup = this.createMediumWeightPopup();
  659.             break;
  660.          case 2:
  661.             this.popup = this.createHeavyWeightPopup();
  662.       }
  663.  
  664.       this.popup.setLocationOnScreen(this.desiredLocationX, this.desiredLocationY);
  665.       this.popup.addComponent(this, "Center");
  666.       ((Container)this).invalidate();
  667.       this.popup.setBackground(((Component)this).getBackground());
  668.       this.popup.pack();
  669.    }
  670.  
  671.    public void setBorderPainted(boolean var1) {
  672.       this.paintBorder = var1;
  673.       ((Component)this).repaint();
  674.    }
  675.  
  676.    public static void setDefaultLightWeightPopupEnabled(boolean var0) {
  677.       SwingUtilities.appContextPut(defaultLWPopupEnabledKey, new Boolean(var0));
  678.    }
  679.  
  680.    public void setInvoker(Component var1) {
  681.       Component var2 = this.invoker;
  682.       this.invoker = var1;
  683.       if (var2 != this.invoker && super.ui != null) {
  684.          super.ui.uninstallUI(this);
  685.          super.ui.installUI(this);
  686.       }
  687.  
  688.       ((Container)this).invalidate();
  689.    }
  690.  
  691.    public void setLabel(String var1) {
  692.       this.label = var1;
  693.       ((JComponent)this).firePropertyChange("label", var1, var1);
  694.       if (super.accessibleContext != null) {
  695.          super.accessibleContext.firePropertyChange("AccessibleVisibleData", var1, var1);
  696.       }
  697.  
  698.       ((Container)this).invalidate();
  699.       ((Component)this).repaint();
  700.    }
  701.  
  702.    public void setLightWeightPopupEnabled(boolean var1) {
  703.       this.lightWeightPopupEnabled = var1;
  704.    }
  705.  
  706.    public void setLocation(int var1, int var2) {
  707.       if (this.popup != null) {
  708.          this.popup.setLocationOnScreen(var1, var2);
  709.       } else {
  710.          this.desiredLocationX = var1;
  711.          this.desiredLocationY = var2;
  712.       }
  713.  
  714.    }
  715.  
  716.    public void setPopupSize(int var1, int var2) {
  717.       if (this.popup != null) {
  718.          this.popup.setSize(var1, var2);
  719.       }
  720.  
  721.    }
  722.  
  723.    public void setPopupSize(Dimension var1) {
  724.       if (this.popup != null) {
  725.          this.popup.setSize(var1.width, var1.height);
  726.       }
  727.  
  728.    }
  729.  
  730.    public void setSelected(Component var1) {
  731.       SingleSelectionModel var2 = this.getSelectionModel();
  732.       int var3 = this.getComponentIndex(var1);
  733.       var2.setSelectedIndex(var3);
  734.    }
  735.  
  736.    public void setSelectionModel(SingleSelectionModel var1) {
  737.       this.selectionModel = var1;
  738.    }
  739.  
  740.    public void setUI(PopupMenuUI var1) {
  741.       super.setUI(var1);
  742.    }
  743.  
  744.    public void setVisible(boolean var1) {
  745.       if (var1 != this.isVisible()) {
  746.          if (!var1) {
  747.             this.getSelectionModel().clearSelection();
  748.          } else if (this.isPopupMenu()) {
  749.             if (this.getSubElements().length > 0) {
  750.                MenuElement[] var2 = new MenuElement[]{this, this.getSubElements()[0]};
  751.                MenuSelectionManager.defaultManager().setSelectedPath(var2);
  752.             } else {
  753.                MenuElement[] var6 = new MenuElement[]{this};
  754.                MenuSelectionManager.defaultManager().setSelectedPath(var6);
  755.             }
  756.          }
  757.  
  758.          if (var1) {
  759.             boolean var4 = this.ancestorIsModalDialog(this.invoker);
  760.             this.firePopupMenuWillBecomeVisible();
  761.             switch (this.lastPopupType) {
  762.                case 0:
  763.                   this.popup = this.createLightWeightPopup();
  764.                   break;
  765.                case 1:
  766.                   this.popup = this.createMediumWeightPopup();
  767.                   break;
  768.                case 2:
  769.                   this.popup = this.createHeavyWeightPopup();
  770.             }
  771.  
  772.             int var7 = this.lastPopupType;
  773.             this.popup.setLocationOnScreen(this.desiredLocationX, this.desiredLocationY);
  774.             this.popup.addComponent(this, "Center");
  775.             this.popup.setBackground(((Component)this).getBackground());
  776.             this.popup.pack();
  777.             Rectangle var5 = new Rectangle(this.desiredLocationX, this.desiredLocationY, this.popup.getWidth(), this.popup.getHeight());
  778.             byte var3;
  779.             if (this.popupFit(var5)) {
  780.                if (this.lightWeightPopupEnabled) {
  781.                   var3 = 0;
  782.                } else {
  783.                   var3 = 1;
  784.                }
  785.             } else if (var4) {
  786.                var3 = 1;
  787.             } else {
  788.                var3 = 2;
  789.             }
  790.  
  791.             if (this.invokerInHeavyWeightPopup(this.invoker)) {
  792.                var3 = 2;
  793.             }
  794.  
  795.             if (this.invoker == null) {
  796.                var3 = 2;
  797.             }
  798.  
  799.             if (var3 != var7) {
  800.                this.replacePopup(var3);
  801.                var7 = var3;
  802.             }
  803.  
  804.             this.lastPopupType = var7;
  805.             this.popup.show(this.invoker);
  806.          } else if (this.popup != null) {
  807.             this.firePopupMenuWillBecomeInvisible();
  808.             this.popup.hide();
  809.             this.popup.removeComponent(this);
  810.             recyclePopup(this.popup);
  811.             this.popup = null;
  812.          }
  813.  
  814.          if (super.accessibleContext != null) {
  815.             if (var1) {
  816.                super.accessibleContext.firePropertyChange("AccessibleState", (Object)null, AccessibleState.VISIBLE);
  817.             } else {
  818.                super.accessibleContext.firePropertyChange("AccessibleState", AccessibleState.VISIBLE, (Object)null);
  819.             }
  820.          }
  821.  
  822.       }
  823.    }
  824.  
  825.    public void show(Component var1, int var2, int var3) {
  826.       this.setInvoker(var1);
  827.       Frame var4 = getFrame(var1);
  828.       if (var4 != this.frame && var4 != null) {
  829.          this.frame = var4;
  830.          if (this.popup != null) {
  831.             this.setVisible(false);
  832.          }
  833.       }
  834.  
  835.       if (var1 != null) {
  836.          Point var5 = var1.getLocationOnScreen();
  837.          this.setLocation(var5.x + var2, var5.y + var3);
  838.       } else {
  839.          this.setLocation(var2, var3);
  840.       }
  841.  
  842.       this.setVisible(true);
  843.    }
  844.  
  845.    public void updateUI() {
  846.       this.setUI((PopupMenuUI)UIManager.getUI(this));
  847.    }
  848.  
  849.    private void writeObject(ObjectOutputStream var1) throws IOException {
  850.       Vector var2 = new Vector();
  851.       var1.defaultWriteObject();
  852.       if (this.invoker != null && this.invoker instanceof Serializable) {
  853.          var2.addElement("invoker");
  854.          var2.addElement(this.invoker);
  855.       }
  856.  
  857.       if (this.popup != null && this.popup instanceof Serializable) {
  858.          var2.addElement("popup");
  859.          var2.addElement(this.popup);
  860.       }
  861.  
  862.       if (this.frame != null && this.frame instanceof Serializable) {
  863.          var2.addElement("frame");
  864.          var2.addElement(this.frame);
  865.       }
  866.  
  867.       var1.writeObject(var2);
  868.       if (super.ui != null && this.getUIClassID().equals("PopupMenuUI")) {
  869.          super.ui.installUI(this);
  870.       }
  871.  
  872.    }
  873. }
  874.