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

Incorrect exception throwing in PopupMenu.show() method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • client-libs
    • None
    • b45
    • generic
    • generic
    • Verified

      PopupMenu.show() is not always throwing IllegalArgumentException
      Incorrect exception throwing can be demonstrated on following example:

      import java.awt.*;
      import java.awt.event.*;


      public class PopupMenuShowExceptions
      {

          public static void main(String args[]) throws Exception {
              Frame f = new Frame();
              Button b = new Button();
              Label l = new Label();
              PopupMenu pm1 = new PopupMenu();

              f.add(l);
              f.show();
              Robot r = null;
              try {
                  r = new Robot();
              } catch (Exception ex) {
                  Sysout.println("Error creating robot");
                  return;
              }

              r.delay(1000);
              try {
                  l.add(pm1);
                  pm1.show(b, 0, 0);
                  r.delay(1000);
                  Sysout.println("Exception is not thrown when showing Popup Menu on component not in parent's hierarchy");
                  return;
              } catch (IllegalArgumentException ex) {
                  Sysout.println( "Correct exception when showing popup menu on non-created component");
                  Sysout.println("Exception: " + ex);
                  return;
              } catch (Exception ex) {
                  Sysout.println("Incorrect exception thrown: " + ex);
                  return;
              }
              Sysout.println();
            
          }//End init()
      }
      ###@###.### 2005-06-01 13:08:25 GMT

            vbaranovsunw Vyacheslav Baranov (Inactive)
            vbaranovsunw Vyacheslav Baranov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: