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

AWT Choice component performance with Windows

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 5.0
    • client-libs
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      If we add a lot of labels to a choice AWT component, it can take minutes to display de updated Choice with Windows. Under Linux, it can takes few seconds only.

      JUSTIFICATION :
      I don't understand this differences in performances, and I need to use AWT Components for WIndows.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The same performances as for Linux.
      ACTUAL -
      When I add 20,000 labels to a Choice, it can take up to 1 minute to finish.

      ---------- BEGIN SOURCE ----------
      The applet that demonstrate the problem:
      -------------------------------------------------------

      package applet;

      import java.applet.Applet;
      import java.awt.Button;
      import java.awt.Choice;
      import java.awt.Dimension;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      /**
       * This program shows the time taken to update an AWT Choice with a lot of
       * labels.
       * <p>
       * The fact is that with Microsoft Windows, it take almost 1 minute. But with
       * Linux, it takes less than 1 second.
       * <p>
       * I am using the SUN JRE 1.6.0-b105, but with JRE 1.5.0-10, I have the same
       * results.
       */
      @SuppressWarnings("serial")
      public class AwtProblem extends Applet {

      public void init() {
      /**
      * A choice list
      */
      final Choice listePistesChoice = new Choice() {
      public Dimension getMinimumSize() {
      Dimension dim = super.getMinimumSize();
      dim.width = 100;
      return dim;
      }

      public Dimension getPreferredSize() {
      return getMinimumSize();
      }
      };
      add(listePistesChoice);

      /**
      * A button to change the labels in the choice list
      */
      Button changeListeNomsPisteButton = new Button("change labels in the choice list");
      changeListeNomsPisteButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      long start = System.currentTimeMillis();
      // Remove all the current content
      listePistesChoice.removeAll();
      // Add the new labels to the choice list
      for (int i = 0; i < 20000; i++) {
      listePistesChoice.add("name:" + i);
      }
      long end = System.currentTimeMillis();
      System.out.println("Time to update:" + (end - start) + "ms");
      }

      });
      add(changeListeNomsPisteButton);
      }
      }



      The HTML to launch the applet:
      ------------------------------------------

      <html>

      <head>
      <title>Awt problem</title>
      </head>

      <body>
      <applet code="applet.AwtProblem"/>
      </body>

      </html>


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

      CUSTOMER SUBMITTED WORKAROUND :
      Use a SWING JComboBox insteed of the AWT Choice.
      But, everywhere, I have been told to not mix AWT and SWING components.

            dav Andrei Dmitriev (Inactive)
            dav Andrei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: