Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6367892

Choice() is inconsistant between releases & AWT_TOOLKIT=MToolkit

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: client-libs
    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      x86
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0-rc"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b64)
      Java HotSpot(TM) Client VM (build 1.6.0-rc-b64, mixed mode, sharing)
      ------------------------------------------
      java version "1.4.2_08"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
      Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
      ----------------------------------------------
      java version "1.5.0_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)


      A DESCRIPTION OF THE PROBLEM :
      When clicking on the choice button ( not a choice item ), I would like to get the mouse clicked event BEFORE the choice items are showed. When I get the event, I would like to erase the past valid current item list, and replace it with a new valid item list. This does not work, and mostly works depending on what JDK you are using, and if the AWT_TOOLKIT=MToolkit is set in the user environment.
      With JDK1.4, the click event does not arrive till after an item has been selected. On 1.5, and 1.6 the click event arrived before the items are shown.
      With JDK16 and AWT_TOOLKIT=null, I can on-the-fly change the choice item list, and it seems to display, but the itemlist collapses to 1 viewable item.
      with JDK16 and AWT_TOOLKIT=MToolkit, clicking on the Choice button yield an invisible item list. You can click on an invisible item, and it appears to be selected. When i click on the checkbox, the wrong state of the checkbox is returned. I think it should be true, but it returns false. When I click on the choice button, the screen is also invisible, and itemlist collapses as if I never clicked on the choice.

      There is also an issue with the boolean state of the checkbox. I believe i reported this already.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run program.
      click on choice box, and view item list.
      click on check-box. click on choice-box. Old item list should be replaced with new item list.
      click on check-box, click on choice box. New item list should be replace with old item list.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I really dunno. There are quite a few errors that are demonstrated with this simple program.
      ACTUAL -
      various results, nothing consistant.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      export AWT_TOOLKIT=MToolkit
      export CLASSPATH=/home/gat/JAVA/NetBeans_Projects/ChoiceGui/build/classes
      #/home/WorkingDirectory/jGPS/jGPS/rungps.sh
      /home/gat/JAVA/JDK16/jdk1.6.0/bin/java -version
      /home/gat/JAVA/JDK16/jdk1.6.0/bin/java choicegui/ChoiceGui
      #/home/gat/JAVA/JDK15/jdk1.5.0_05/bin/java -version
      #/home/gat/JAVA/JDK15/jdk1.5.0_05/bin/java choicegui/ChoiceGui
      #/home/gat/JAVA/JDK14/j2sdk1.4.2_08/bin/java -version
      #/home/gat/JAVA/JDK14/j2sdk1.4.2_08/bin/java choicegui/ChoiceGui
      ==================================================

      /*
       * ChoiceGui.java
       *
       * Created on December 23, 2005, 12:06 PM
       */

      package choicegui;

      /**
       *
       * @author gat
       */
      public class ChoiceGui extends java.awt.Frame {
          
          /** Creates new form ChoiceGui */
          static final String[] old = { "1km","2km", "3km", "100km", "200km", "500km", "550km", "600km", "700km","800km", "900km" };
          static final String[] gnu = { "1mi", "2mi", "3mi","4mi", "5mi", "6mi", "7mi", "12mu", "13MI", "14mi", "19mi" };
          boolean fillWithGnuItems, filledWithOldItems;
          boolean checkboxClickedFirstTime;
          
          public ChoiceGui() {
              initComponents();
              this.setSize( 300, 100 );
              fillWithOldChoiceItems();
              fillWithGnuItems = false;
              checkbox.setState( fillWithGnuItems );
              checkboxClickedFirstTime = false;
          }
          
          /** This method is called from within the constructor to
           * initialize the form.
           * WARNING: Do NOT modify this code. The content of this method is
           * always regenerated by the Form Editor.
           */
          // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
          private void initComponents() {
              java.awt.GridBagConstraints gridBagConstraints;

              panel1 = new java.awt.Panel();
              checkbox = new java.awt.Checkbox();
              choice = new java.awt.Choice();

              addWindowListener(new java.awt.event.WindowAdapter() {
                  public void windowClosing(java.awt.event.WindowEvent evt) {
                      exitForm(evt);
                  }
              });

              panel1.setLayout(new java.awt.GridBagLayout());

              checkbox.setLabel("NewChoiceItems");
              checkbox.addMouseListener(new java.awt.event.MouseAdapter() {
                  public void mouseClicked(java.awt.event.MouseEvent evt) {
                      checkboxMouseClicked(evt);
                  }
              });

              gridBagConstraints = new java.awt.GridBagConstraints();
              gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 30);
              panel1.add(checkbox, gridBagConstraints);

              choice.addMouseListener(new java.awt.event.MouseAdapter() {
                  public void mouseClicked(java.awt.event.MouseEvent evt) {
                      choiceMouseClicked(evt);
                  }
              });

              panel1.add(choice, new java.awt.GridBagConstraints());

              add(panel1, java.awt.BorderLayout.CENTER);

              pack();
          }
          // </editor-fold>

          private void checkboxMouseClicked(java.awt.event.MouseEvent evt) {
          // TODO add your handling code here:
              boolean cbVal = checkbox.getState();
              if ( checkboxClickedFirstTime == false && cbVal == false ) {
                  System.out.println(" ***** checkbox returned wrong state should be \"true\" . *******");
              }
              checkboxClickedFirstTime = true;
              fillWithGnuItems = cbVal;
              System.out.println("CheckBox clicked val="+cbVal);
          }

          private void choiceMouseClicked(java.awt.event.MouseEvent evt) {
      // TODO add your handling code here:
              System.out.println("choiceMouseClicked(); fillWithGnuItems="+fillWithGnuItems+", filledWithOldItems="+filledWithOldItems);
              if ( fillWithGnuItems == true && filledWithOldItems == true )
                  fillWithGnuChoiceItems();
              if ( filledWithOldItems == false && fillWithGnuItems == false )
                  fillWithOldChoiceItems();
          }
          
          void fillWithOldChoiceItems() {
              choice.removeAll();
              for ( int i=0; i < old.length; i++ )
                  choice.add( old[i]);
              this.validate();
              this.invalidate();
              filledWithOldItems = true;
          }
         void fillWithGnuChoiceItems() {
              choice.removeAll();
              for ( int i=0; i < gnu.length; i++ )
                  choice.add( gnu[i]);
              this.invalidate();
              this.validate();
              filledWithOldItems = false;
          }
         
         /** Exit the Application */
          private void exitForm(java.awt.event.WindowEvent evt) {
              System.exit(0);
          }
          
          /**
           * @param args the command line arguments
           */
          public static void main(String args[]) {
              java.awt.EventQueue.invokeLater(new Runnable() {
                  public void run() {
                      new ChoiceGui().setVisible(true);
                  }
              });
          }
          
          
          // Variables declaration - do not modify
          private java.awt.Checkbox checkbox;
          private java.awt.Choice choice;
          private java.awt.Panel panel1;
          // End of variables declaration
          
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      i got none.

        Attachments

          Activity

            People

            Assignee:
            dav Andrei Dmitriev (Inactive)
            Reporter:
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: