home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / JDPComboBox.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-09  |  11.9 KB  |  903 lines

  1. import java.awt.BorderLayout;
  2. import java.awt.Button;
  3. import java.awt.Choice;
  4. import java.awt.Color;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Dimension;
  8. import java.awt.Event;
  9. import java.awt.Font;
  10. import java.awt.FontMetrics;
  11. import java.awt.Graphics;
  12. import java.awt.Panel;
  13. import java.awt.Rectangle;
  14. import java.awt.TextField;
  15. import java.awt.Window;
  16. import java.util.Date;
  17. import java.util.Vector;
  18.  
  19. public class JDPComboBox extends Panel {
  20.    JDPButton downButton;
  21.    TextField text;
  22.    Choice thisChoice;
  23.    JDPList list;
  24.    Vector displayVector;
  25.    Vector actualVector;
  26.    JDPUser user;
  27.    JDPPopupComponent popup;
  28.    JDPPopupWindow popupw;
  29.    int totalHeight;
  30.    long lastEventTime;
  31.    long popupHiddenTime;
  32.    Font currentFont;
  33.    Color fgColor;
  34.    Color bgColor;
  35.    boolean usePopup;
  36.    Container parent;
  37.    boolean popupShowing;
  38.    int minimumWidth = 30;
  39.    int minimumHeight = 10;
  40.    int maximumWidth = 250;
  41.    int maximumHeight = 60;
  42.  
  43.    void selectPopupType() {
  44.       if (this.parent == null) {
  45.          this.parent = super.getParent();
  46.          if (this.parent != null) {
  47.             for(; !(this.parent instanceof Window); this.parent = this.parent.getParent()) {
  48.                if (this.parent instanceof JDesignerPro) {
  49.                   this.usePopup = true;
  50.                }
  51.             }
  52.  
  53.             if (this.parent instanceof JDPMainWindow) {
  54.                this.usePopup = true;
  55.             }
  56.  
  57.             if (this.parent instanceof JDPSetup) {
  58.                this.usePopup = true;
  59.             }
  60.          }
  61.       }
  62.  
  63.    }
  64.  
  65.    void initCombo(JDPUser var1, String var2, int var3) {
  66.       this.usePopup = false;
  67.       this.user = var1;
  68.       this.setUser(var1);
  69.       if (var1 != null) {
  70.          this.list = new JDPList(var1);
  71.          this.list.setScrollSouthDisabled(true);
  72.       }
  73.  
  74.       this.downButton = new JDPButton(5);
  75.       this.text = new TextField(var2, var3);
  76.       ((Container)this).setLayout(new BorderLayout());
  77.       this.displayVector = new Vector();
  78.       this.actualVector = new Vector();
  79.       this.initChoice();
  80.       Panel var4 = new Panel();
  81.       ((Container)var4).setLayout(new BorderLayout());
  82.       ((Container)var4).add("East", this.downButton);
  83.       ((Container)var4).add("Center", this.text);
  84.       ((Container)this).add("North", var4);
  85.       this.layoutChoice();
  86.       this.lastEventTime = -1L;
  87.    }
  88.  
  89.    public String getSelectedItem() {
  90.       return this.thisChoice.getSelectedItem();
  91.    }
  92.  
  93.    public int countItems() {
  94.       return this.getItemCount();
  95.    }
  96.  
  97.    public void sortItems() {
  98.       this.sortItems(false, true);
  99.    }
  100.  
  101.    public void sortItems(boolean var1, boolean var2) {
  102.       String var3 = null;
  103.       int var4 = 0;
  104.       int var7 = this.countItems();
  105.  
  106.       for(int var8 = 0; var8 < var7; ++var8) {
  107.          for(int var9 = var8; var9 < var7; ++var9) {
  108.             String var6 = (String)this.displayVector.elementAt(var9);
  109.             if (var1) {
  110.                var6 = var6.toLowerCase();
  111.             }
  112.  
  113.             if (var3 == null || var2 && var6.compareTo(var3) < 0 || !var2 && var6.compareTo(var3) > 0) {
  114.                var3 = var6;
  115.                var4 = var9;
  116.             }
  117.          }
  118.  
  119.          if (var8 < var4 || var4 != 0) {
  120.             String var5 = (String)this.displayVector.elementAt(var8);
  121.             this.displayVector.setElementAt(this.displayVector.elementAt(var4), var8);
  122.             this.displayVector.setElementAt(var5, var4);
  123.             var5 = (String)this.actualVector.elementAt(var8);
  124.             this.actualVector.setElementAt(this.actualVector.elementAt(var4), var8);
  125.             this.actualVector.setElementAt(var5, var4);
  126.          }
  127.  
  128.          var3 = null;
  129.          var4 = 0;
  130.       }
  131.  
  132.       this.reloadChoice();
  133.    }
  134.  
  135.    void setUser(JDPUser var1) {
  136.       this.user = var1;
  137.       if (var1 != null) {
  138.          this.popupw = new JDPPopupWindow(var1, this);
  139.          if (var1.popup != null) {
  140.             this.popup = var1.popup;
  141.          }
  142.       }
  143.    }
  144.  
  145.    void getUser() {
  146.       if (this.user == null && ((Component)this).getParent() != null) {
  147.          Container var1;
  148.          for(var1 = ((Component)this).getParent(); var1 != null && !(var1 instanceof JDPMainWindow) && !(var1 instanceof JDPSingle) && !(var1 instanceof JDesignerPro) && !(var1 instanceof JDPDialog); var1 = ((Component)var1).getParent()) {
  149.          }
  150.  
  151.          if (var1 != null) {
  152.             if (var1 instanceof JDPMainWindow) {
  153.                this.user = ((JDPMainWindow)var1).user;
  154.             }
  155.  
  156.             if (var1 instanceof JDPSingle) {
  157.                this.user = ((JDPSingle)var1).user[0];
  158.             }
  159.  
  160.             if (var1 instanceof JDesignerPro) {
  161.                this.user = ((JDesignerPro)var1).user[0];
  162.             }
  163.  
  164.             if (var1 instanceof JDPDialog) {
  165.                this.user = ((JDPDialog)var1).user;
  166.             }
  167.  
  168.             this.setUser(this.user);
  169.          }
  170.       }
  171.  
  172.    }
  173.  
  174.    public void select(int var1) {
  175.       if (var1 >= 0 && var1 < this.thisChoice.countItems()) {
  176.          this.thisChoice.select(var1);
  177.          this.text.setText(this.thisChoice.getSelectedItem());
  178.       }
  179.  
  180.    }
  181.  
  182.    public void select(String var1) {
  183.       this.thisChoice.select(var1);
  184.       if (this.thisChoice.getSelectedItem() != null) {
  185.          this.text.setText(this.thisChoice.getSelectedItem());
  186.       } else {
  187.          this.text.setText("");
  188.       }
  189.    }
  190.  
  191.    void displayPulldown() {
  192.       if (this.popup == null) {
  193.          this.getUser();
  194.       }
  195.  
  196.       this.selectPopupType();
  197.       if (!this.usePopup || !this.popupShowing && this.thisChoice.countItems() != 0) {
  198.          if (this.usePopup || !this.popupShowing && this.thisChoice.countItems() != 0) {
  199.             this.popupShowing = true;
  200.             int var1 = ((Component)this).bounds().x;
  201.             int var2 = ((Component)this).bounds().y;
  202.             Container var3 = ((Component)this).getParent();
  203.             if (this.usePopup) {
  204.                while(var3 != null && !var3.equals(this.popup.getParent())) {
  205.                   Rectangle var5 = ((Component)var3).bounds();
  206.                   var1 += var5.x;
  207.                   var2 += var5.y;
  208.                   var3 = ((Component)var3).getParent();
  209.                }
  210.             } else {
  211.                while(var3 != null && !var3.equals(this.popupw.getParent())) {
  212.                   Rectangle var4 = ((Component)var3).bounds();
  213.                   var1 += var4.x;
  214.                   var2 += var4.y;
  215.                   var3 = ((Component)var3).getParent();
  216.                }
  217.             }
  218.  
  219.             this.loadPulldown();
  220.             if (this.usePopup) {
  221.                this.popup.display(var1 + 1, var2 + this.text.bounds().height, var2);
  222.                this.popup.setEventListener(this);
  223.             } else {
  224.                this.popupw.display(var1 + 1, var2 + this.text.bounds().height, var2);
  225.                this.popupw.setEventListener(this);
  226.             }
  227.  
  228.             this.list.requestFocus();
  229.          } else {
  230.             if (this.popupw.getEventListener() != null && this.popupw.getEventListener().equals(this)) {
  231.                this.popupw.hide();
  232.             }
  233.  
  234.             this.popupShowing = false;
  235.          }
  236.       } else {
  237.          if (this.popup.getEventListener() != null && this.popup.getEventListener().equals(this)) {
  238.             this.popup.hide();
  239.          }
  240.  
  241.          this.popupShowing = false;
  242.       }
  243.    }
  244.  
  245.    void loadPulldown() {
  246.       if (this.user != null && this.list == null) {
  247.          this.list = new JDPList(this.user);
  248.          this.list.setScrollSouthDisabled(true);
  249.       }
  250.  
  251.       this.list.setFont(this.text.getFont());
  252.       this.list.setForeground(this.text.getForeground());
  253.       if (!this.text.getBackground().equals(Color.lightGray)) {
  254.          this.list.setBackground(this.text.getBackground());
  255.       }
  256.  
  257.       FontMetrics var1 = this.downButton.getGraphics().getFontMetrics();
  258.       int var2 = var1.getHeight() + 2;
  259.       this.totalHeight = this.thisChoice.countItems() * var2 + 5;
  260.       if (this.usePopup) {
  261.          this.popup.removeAll();
  262.          this.popup.setFont(this.getFont());
  263.          this.popup.setForeground(this.getForeground());
  264.          this.popup.setBackground(this.getBackground());
  265.          this.popup.add("Center", this.list);
  266.       } else {
  267.          this.popupw.removeAll();
  268.          this.popupw.setFont(this.getFont());
  269.          this.popupw.setForeground(this.getForeground());
  270.          this.popupw.setBackground(this.getBackground());
  271.          this.popupw.add("Center", this.list);
  272.       }
  273.  
  274.       this.list.setMinWidth(((Component)this).bounds().width - 2);
  275.       this.list.setMinHeight(this.totalHeight);
  276.       this.list.threeDBorder = false;
  277.       this.list.clear();
  278.  
  279.       for(int var3 = 0; var3 < this.thisChoice.countItems(); ++var3) {
  280.          this.list.addItem(this.thisChoice.getItem(var3));
  281.       }
  282.  
  283.       this.list.select(this.text.getText());
  284.       this.list.makeVisible(this.list.getSelectedIndex());
  285.    }
  286.  
  287.    public int getItemCount() {
  288.       return this.displayVector.size();
  289.    }
  290.  
  291.    public void enable() {
  292.       this.text.enable();
  293.       this.downButton.enable();
  294.    }
  295.  
  296.    public void disable() {
  297.       this.text.disable();
  298.       this.downButton.disable();
  299.    }
  300.  
  301.    public void setMinimumHeight(int var1) {
  302.       this.minimumHeight = var1;
  303.    }
  304.  
  305.    void selectKey(String var1) {
  306.       int var2;
  307.       if ((var2 = this.actualVector.indexOf(var1)) >= 0) {
  308.          this.select(var2);
  309.       }
  310.  
  311.    }
  312.  
  313.    String getItemForKey(String var1) {
  314.       int var2;
  315.       return (var2 = this.actualVector.indexOf(var1)) >= 0 ? (String)this.displayVector.elementAt(var2) : null;
  316.    }
  317.  
  318.    public Dimension preferredSize() {
  319.       return this.minimumSize();
  320.    }
  321.  
  322.    public int getMinimumHeight() {
  323.       return this.minimumHeight;
  324.    }
  325.  
  326.    public void setMaximumWidth(int var1) {
  327.       this.maximumWidth = var1;
  328.    }
  329.  
  330.    public int getMaximumWidth() {
  331.       return this.maximumWidth;
  332.    }
  333.  
  334.    public void remove(int var1) {
  335.       if (this.displayVector != null) {
  336.          if (var1 < this.displayVector.size()) {
  337.             this.displayVector.removeElementAt(var1);
  338.             this.actualVector.removeElementAt(var1);
  339.             this.reloadChoice();
  340.          }
  341.  
  342.       }
  343.    }
  344.  
  345.    public void remove(String var1) {
  346.       for(int var2 = 0; var2 < this.displayVector.size(); ++var2) {
  347.          if (((String)this.displayVector.elementAt(var2)).equals(var1)) {
  348.             this.remove(var2);
  349.             return;
  350.          }
  351.       }
  352.  
  353.    }
  354.  
  355.    public void loadChoice(JDPUser var1, JDPJagg var2, String var3, String var4, String var5, String var6) {
  356.       this.initChoice();
  357.       this.displayVector = new Vector();
  358.       this.actualVector = new Vector();
  359.       new JDPLoadChoice(var1, var2, this.thisChoice, var3, var4, var5, var6, this.actualVector);
  360.  
  361.       for(int var7 = 0; var7 < this.thisChoice.countItems(); ++var7) {
  362.          this.displayVector.addElement(this.thisChoice.getItem(var7));
  363.       }
  364.  
  365.       this.layoutChoice();
  366.    }
  367.  
  368.    public void loadChoice(JDPUser var1, JDPJagg var2, String var3, String var4, String var5) {
  369.       this.initChoice();
  370.       this.displayVector = new Vector();
  371.       this.actualVector = new Vector();
  372.       new JDPLoadChoice(var1, var2, this.thisChoice, var3, var4, var5);
  373.  
  374.       for(int var6 = 0; var6 < this.thisChoice.countItems(); ++var6) {
  375.          this.displayVector.addElement(this.thisChoice.getItem(var6));
  376.          this.actualVector.addElement(this.thisChoice.getItem(var6));
  377.       }
  378.  
  379.       this.layoutChoice();
  380.    }
  381.  
  382.    public void loadChoice(String[] var1) {
  383.       this.initChoice();
  384.       this.displayVector = new Vector();
  385.       this.actualVector = new Vector();
  386.       if (var1 != null) {
  387.          for(int var2 = 0; var2 < var1.length; ++var2) {
  388.             if (var1[var2] != null && var1[var2].length() > 0) {
  389.                this.addItem(var1[var2]);
  390.             }
  391.          }
  392.  
  393.          this.layoutChoice();
  394.       }
  395.    }
  396.  
  397.    public void loadChoice(String[] var1, String[] var2) {
  398.       this.initChoice();
  399.       this.displayVector = new Vector();
  400.       this.actualVector = new Vector();
  401.       if (var1 != null && var2 != null && var1.length == var2.length) {
  402.          for(int var3 = 0; var3 < var1.length; ++var3) {
  403.             if (var1[var3] != null && var1[var3].length() > 0 && var2[var3] != null && var2[var3].length() > 0) {
  404.                this.addItem(var1[var3], var2[var3]);
  405.             }
  406.          }
  407.  
  408.          this.layoutChoice();
  409.       }
  410.    }
  411.  
  412.    void initChoice() {
  413.       this.thisChoice = null;
  414.       this.thisChoice = new Choice();
  415.    }
  416.  
  417.    public void layoutChoice() {
  418.       ((Container)this).layout();
  419.       ((Component)this).paintAll(((Component)this).getGraphics());
  420.       if (((Component)this).getParent() != null) {
  421.          ((Component)this).getParent().layout();
  422.          ((Component)this).getParent().paintAll(((Component)this).getParent().getGraphics());
  423.       }
  424.  
  425.    }
  426.  
  427.    public void setBackground(Color var1) {
  428.       this.bgColor = var1;
  429.       this.text.setBackground(var1);
  430.       if (this.list != null && !var1.equals(Color.lightGray)) {
  431.          this.list.setBackground(var1);
  432.       }
  433.  
  434.       if (!var1.equals(Color.white)) {
  435.          this.downButton.setBackground(var1);
  436.       }
  437.  
  438.    }
  439.  
  440.    public Color getBackground() {
  441.       if (this.bgColor != null) {
  442.          return this.bgColor;
  443.       } else {
  444.          Container var1 = ((Component)this).getParent();
  445.          return var1 != null ? ((Component)var1).getBackground() : null;
  446.       }
  447.    }
  448.  
  449.    public String getItem(int var1) {
  450.       return var1 >= 0 && var1 < this.thisChoice.countItems() ? this.thisChoice.getItem(var1) : null;
  451.    }
  452.  
  453.    public int getItem(String var1) {
  454.       for(int var2 = 0; var2 < this.displayVector.size(); ++var2) {
  455.          if (((String)this.displayVector.elementAt(var2)).equals(var1)) {
  456.             return var2;
  457.          }
  458.       }
  459.  
  460.       return -1;
  461.    }
  462.  
  463.    void reloadChoice() {
  464.       this.initChoice();
  465.  
  466.       for(int var1 = 0; var1 < this.displayVector.size(); ++var1) {
  467.          this.thisChoice.addItem((String)this.displayVector.elementAt(var1));
  468.       }
  469.  
  470.       this.layoutChoice();
  471.    }
  472.  
  473.    public void setEditable(boolean var1) {
  474.       if (this.text != null) {
  475.          this.text.setEditable(var1);
  476.       }
  477.  
  478.    }
  479.  
  480.    public boolean getEditable() {
  481.       return this.text.isEditable();
  482.    }
  483.  
  484.    public Dimension minimumSize() {
  485.       Dimension var1 = new Dimension(20, 12);
  486.       if (this.text != null) {
  487.          var1 = ((Component)this.text).minimumSize();
  488.          int var2 = 0;
  489.          Graphics var3 = ((Component)this).getGraphics();
  490.          if (this.user == null) {
  491.             this.getUser();
  492.          }
  493.  
  494.          if (this.thisChoice != null && this.downButton != null && this.user != null) {
  495.             for(int var4 = 0; var4 < this.thisChoice.countItems(); ++var4) {
  496.                int var5 = this.user.u.StringWidth(var3, this.thisChoice.getItem(var4));
  497.                if (var5 > var2) {
  498.                   var2 = var5;
  499.                }
  500.             }
  501.  
  502.             if (var2 > 0) {
  503.                var1.width = var2 + 30;
  504.             }
  505.          }
  506.       }
  507.  
  508.       if (var1.width < this.minimumWidth) {
  509.          var1.width = this.minimumWidth;
  510.       }
  511.  
  512.       if (var1.width > this.maximumWidth) {
  513.          var1.width = this.maximumWidth;
  514.       }
  515.  
  516.       if (var1.height < this.minimumHeight) {
  517.          var1.height = this.minimumHeight;
  518.       }
  519.  
  520.       if (var1.height > this.maximumHeight) {
  521.          var1.height = this.maximumHeight;
  522.       }
  523.  
  524.       return var1;
  525.    }
  526.  
  527.    String getItemKey(String var1) {
  528.       for(int var2 = 0; var2 < this.displayVector.size(); ++var2) {
  529.          if (((String)this.displayVector.elementAt(var2)).equals(var1)) {
  530.             return (String)this.actualVector.elementAt(var2);
  531.          }
  532.       }
  533.  
  534.       return null;
  535.    }
  536.  
  537.    public void setFont(Font var1) {
  538.       this.currentFont = var1;
  539.       this.text.setFont(var1);
  540.       if (this.list != null) {
  541.          this.list.setFont(var1);
  542.       }
  543.  
  544.       this.downButton.setFont(var1);
  545.    }
  546.  
  547.    public Font getFont() {
  548.       if (this.currentFont == null && ((Component)this).getParent() != null) {
  549.          this.currentFont = ((Component)this).getParent().getFont();
  550.       }
  551.  
  552.       return this.currentFont;
  553.    }
  554.  
  555.    public JDPComboBox(JDPUser var1) {
  556.       this.initCombo(var1, "", 20);
  557.    }
  558.  
  559.    public JDPComboBox(JDPUser var1, int var2) {
  560.       this.initCombo(var1, "", var2);
  561.    }
  562.  
  563.    public JDPComboBox(JDPUser var1, String var2, int var3) {
  564.       this.initCombo(var1, var2, var3);
  565.    }
  566.  
  567.    public void addItem(String var1) {
  568.       this.thisChoice.addItem(var1);
  569.       this.displayVector.addElement(var1);
  570.       this.actualVector.addElement(var1);
  571.       this.text.setText(this.thisChoice.getSelectedItem());
  572.    }
  573.  
  574.    public void addItem(String var1, String var2) {
  575.       this.thisChoice.addItem(var1);
  576.       this.displayVector.addElement(var1);
  577.       this.actualVector.addElement(var2);
  578.       this.text.setText(this.thisChoice.getSelectedItem());
  579.    }
  580.  
  581.    public void setMinimumWidth(int var1) {
  582.       this.minimumWidth = var1;
  583.    }
  584.  
  585.    public int getMinimumWidth() {
  586.       return this.minimumWidth;
  587.    }
  588.  
  589.    public int getSelectedIndex() {
  590.       return this.thisChoice.getSelectedIndex();
  591.    }
  592.  
  593.    public void setMaximumHeight(int var1) {
  594.       this.maximumHeight = var1;
  595.    }
  596.  
  597.    public void clear() {
  598.       this.initChoice();
  599.       this.displayVector = new Vector();
  600.       this.actualVector = new Vector();
  601.       this.layoutChoice();
  602.    }
  603.  
  604.    public int getMaximumHeight() {
  605.       return this.maximumHeight;
  606.    }
  607.  
  608.    String getSelectedKey() {
  609.       String var1 = "";
  610.       if (this.thisChoice.getSelectedIndex() >= 0 && this.thisChoice.getSelectedIndex() < this.actualVector.size()) {
  611.          var1 = (String)this.actualVector.elementAt(this.thisChoice.getSelectedIndex());
  612.       }
  613.  
  614.       return var1;
  615.    }
  616.  
  617.    String[] getSelectedKeyValue() {
  618.       if (this.thisChoice.getSelectedIndex() >= 0 && this.thisChoice.getSelectedIndex() < this.actualVector.size()) {
  619.          String[] var1 = new String[]{(String)this.actualVector.elementAt(this.thisChoice.getSelectedIndex())};
  620.          return var1;
  621.       } else {
  622.          return null;
  623.       }
  624.    }
  625.  
  626.    public void setForeground(Color var1) {
  627.       this.fgColor = var1;
  628.       this.text.setForeground(var1);
  629.       if (this.list != null) {
  630.          this.list.setForeground(var1);
  631.       }
  632.  
  633.       this.downButton.setForeground(var1);
  634.    }
  635.  
  636.    public Color getForeground() {
  637.       if (this.fgColor != null) {
  638.          return this.fgColor;
  639.       } else {
  640.          Container var1 = ((Component)this).getParent();
  641.          return var1 != null ? ((Component)var1).getForeground() : null;
  642.       }
  643.    }
  644.  
  645.    public void setEnabled(boolean var1) {
  646.       if (var1) {
  647.          this.text.enable();
  648.          this.downButton.enable();
  649.       } else {
  650.          this.text.disable();
  651.          this.downButton.disable();
  652.       }
  653.    }
  654.  
  655.    public boolean getEnabled() {
  656.       return this.text.isEnabled();
  657.    }
  658.  
  659.    public boolean handleEvent(Event var1) {
  660.       switch (var1.id) {
  661.          case 401:
  662.             if (var1.key == 9) {
  663.                if (var1.target.equals(this.downButton) || var1.target.equals(this.text)) {
  664.                   this.lastEventTime = (new Date()).getTime();
  665.                   Event var12 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers);
  666.                   ((Component)this).postEvent(var12);
  667.                }
  668.  
  669.                if (var1.target.equals(this.list)) {
  670.                   if (this.usePopup) {
  671.                      if (this.popup.getEventListener().equals(this)) {
  672.                         this.popup.hide();
  673.                      }
  674.                   } else if (this.popupw.getEventListener().equals(this)) {
  675.                      this.popupw.hide();
  676.                   }
  677.                }
  678.             }
  679.  
  680.             return false;
  681.          case 403:
  682.             switch (var1.key) {
  683.                case 1003:
  684.                   if (var1.when > 0L && var1.when - this.popupHiddenTime < 200L) {
  685.                      this.popupShowing = true;
  686.                   }
  687.  
  688.                   this.displayPulldown();
  689.                   return true;
  690.                case 1004:
  691.                   if (this.list != null && this.list.getSelectedIndex() - 1 >= 0) {
  692.                      this.list.select(this.list.getSelectedIndex() - 1);
  693.                      this.thisChoice.select(this.list.getSelectedItem());
  694.                      this.text.setText(this.thisChoice.getSelectedItem());
  695.                      return true;
  696.                   }
  697.  
  698.                   this.displayPulldown();
  699.                   return true;
  700.                case 1005:
  701.                   if (this.list != null && this.list.getSelectedIndex() + 1 < this.list.countItems()) {
  702.                      this.list.select(this.list.getSelectedIndex() + 1);
  703.                      this.thisChoice.select(this.list.getSelectedItem());
  704.                      this.text.setText(this.thisChoice.getSelectedItem());
  705.                      return true;
  706.                   }
  707.  
  708.                   this.displayPulldown();
  709.                   return true;
  710.                default:
  711.                   return false;
  712.             }
  713.          case 701:
  714.             if (!var1.target.equals(this.list)) {
  715.                return true;
  716.             }
  717.  
  718.             this.text.setText(this.list.getSelectedItem());
  719.             this.thisChoice.select(this.list.getSelectedItem());
  720.             this.displayPulldown();
  721.             Event var11 = new Event(this, var1.when, 1001, var1.x, var1.y, var1.key, var1.modifiers, this.list.getSelectedItem());
  722.             ((Component)this).getParent().postEvent(var11);
  723.             if (this.text.isEnabled() && this.text.isEditable()) {
  724.                this.text.requestFocus();
  725.             } else if (this.popupShowing) {
  726.                this.list.requestFocus();
  727.             } else {
  728.                this.downButton.requestFocus();
  729.             }
  730.  
  731.             this.lastEventTime = (new Date()).getTime();
  732.             return true;
  733.          case 1001:
  734.             if (var1.target.equals(this.text)) {
  735.                Event var10 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers, this.text.getText());
  736.                super.postEvent(var10);
  737.                return true;
  738.             } else if (var1.target.equals(this.list)) {
  739.                this.text.setText(this.list.getSelectedItem());
  740.                this.thisChoice.select(this.list.getSelectedItem());
  741.                this.displayPulldown();
  742.                Event var9 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers, this.list.getSelectedItem());
  743.                super.postEvent(var9);
  744.                return true;
  745.             } else if (var1.target.equals(this.downButton)) {
  746.                long var8 = (new Date()).getTime();
  747.                if (var8 - this.lastEventTime < 100L) {
  748.                   if (this.popupShowing) {
  749.                      this.list.requestFocus();
  750.                   } else {
  751.                      this.downButton.requestFocus();
  752.                   }
  753.  
  754.                   this.lastEventTime = (new Date()).getTime();
  755.                   return false;
  756.                }
  757.  
  758.                this.lastEventTime = (new Date()).getTime();
  759.                this.displayPulldown();
  760.                if (this.popupShowing) {
  761.                   this.list.requestFocus();
  762.                } else {
  763.                   this.downButton.requestFocus();
  764.                }
  765.  
  766.                return true;
  767.             } else {
  768.                if (var1.target instanceof Button) {
  769.                   return true;
  770.                }
  771.  
  772.                return false;
  773.             }
  774.          case 1004:
  775.             if (!var1.target.equals(this.downButton) && !var1.target.equals(this) && !var1.target.equals(this.list)) {
  776.                long var6 = (new Date()).getTime();
  777.                if (var6 - this.lastEventTime >= 100L && this.lastEventTime >= 0L) {
  778.                   if (!var1.target.equals(this.text) || this.text.isEnabled() && this.text.isEditable()) {
  779.                      if (!var1.target.equals(this.text) && !var1.target.equals(this.list)) {
  780.                         return true;
  781.                      }
  782.  
  783.                      Event var16 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers, (Object)null);
  784.                      super.deliverEvent(var16);
  785.                      return true;
  786.                   }
  787.  
  788.                   var6 = (new Date()).getTime();
  789.                   if (var6 - this.lastEventTime < 100L) {
  790.                      if (this.popupShowing) {
  791.                         this.list.requestFocus();
  792.                      } else {
  793.                         this.downButton.requestFocus();
  794.                      }
  795.  
  796.                      this.lastEventTime = (new Date()).getTime();
  797.                      return false;
  798.                   }
  799.  
  800.                   this.lastEventTime = (new Date()).getTime();
  801.                   if (this.text.getSelectionEnd() > 0) {
  802.                      this.displayPulldown();
  803.                   }
  804.  
  805.                   if (this.popupShowing) {
  806.                      this.list.requestFocus();
  807.                   } else {
  808.                      this.downButton.requestFocus();
  809.                   }
  810.  
  811.                   Event var15 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers, (Object)null);
  812.                   super.deliverEvent(var15);
  813.                   return false;
  814.                }
  815.  
  816.                this.lastEventTime = (new Date()).getTime();
  817.                if (!this.text.isEnabled() || !this.text.isEditable()) {
  818.                   if (this.popupShowing) {
  819.                      this.list.requestFocus();
  820.                   } else {
  821.                      this.downButton.requestFocus();
  822.                   }
  823.                }
  824.  
  825.                return true;
  826.             }
  827.  
  828.             if (var1.target.equals(this.list)) {
  829.                this.lastEventTime = (new Date()).getTime();
  830.             }
  831.  
  832.             return false;
  833.          case 1005:
  834.             long var2 = (new Date()).getTime();
  835.             if (var2 - this.lastEventTime < 100L) {
  836.                return true;
  837.             } else if (var1.target.equals(this)) {
  838.                return false;
  839.             } else if (var1.target.equals(this.downButton)) {
  840.                return true;
  841.             } else {
  842.                var2 = (new Date()).getTime();
  843.                this.text.select(0, 0);
  844.                if (var2 - this.lastEventTime < 200L) {
  845.                   return true;
  846.                } else if (this.usePopup && var1.target.equals(this.list) && this.popupShowing) {
  847.                   this.lastEventTime = (new Date()).getTime();
  848.                   if (this.popup.getEventListener().equals(this)) {
  849.                      this.popup.hide();
  850.                   }
  851.  
  852.                   this.popupShowing = false;
  853.                   this.popupHiddenTime = (new Date()).getTime();
  854.                   Event var14 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers, (Object)null);
  855.                   super.deliverEvent(var14);
  856.                   return true;
  857.                } else if (!this.usePopup && var1.target.equals(this.list) && this.popupShowing) {
  858.                   this.lastEventTime = (new Date()).getTime();
  859.                   if (this.popupw.getEventListener().equals(this)) {
  860.                      this.popupw.hide();
  861.                   }
  862.  
  863.                   this.popupShowing = false;
  864.                   this.popupHiddenTime = (new Date()).getTime();
  865.                   Event var13 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers, (Object)null);
  866.                   super.deliverEvent(var13);
  867.                   return true;
  868.                } else {
  869.                   if (!var1.target.equals(this.list) && !var1.target.equals(this.text)) {
  870.                      return true;
  871.                   }
  872.  
  873.                   Event var4 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers, (Object)null);
  874.                   super.deliverEvent(var4);
  875.                   return true;
  876.                }
  877.             }
  878.          default:
  879.             if (!var1.target.equals(this.text) && !var1.target.equals(this.list)) {
  880.                return false;
  881.             } else {
  882.                Event var17 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers, (Object)null);
  883.                super.deliverEvent(var17);
  884.                return false;
  885.             }
  886.       }
  887.    }
  888.  
  889.    public void setText(String var1) {
  890.       if (var1 != null) {
  891.          this.text.setText(var1);
  892.          this.thisChoice.select(var1);
  893.       } else {
  894.          this.text.setText("");
  895.          this.thisChoice.select(0);
  896.       }
  897.    }
  898.  
  899.    public String getText() {
  900.       return this.text.getText();
  901.    }
  902. }
  903.