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

FileDialog.setDirectory() throws exception on Linux & Solaris

XMLWordPrintable

    • b51
    • generic
    • linux
    • Verified

      api/java_awt/interactive/ComponentTests.html#ComponentTests[ComponentTest0002] test fails with exception. Fails on Linux and Solaris since b43 and up to b46 , passes before b43. Passes on Windows XP.

      To reproduce:
      1. click "Start Test 2" button
      2. Click "File" menu
      3. click "Open..."
      4. select file and click "Open"
      5. Click "File" menu again and exception will be thrown

      Exception:

      Exception occurred during event dispatching:
      java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
              at java.awt.Component.getLocationOnScreen_NoTreeLock(Unknown Source)
              at java.awt.Component.getLocationOnScreen(Unknown Source)
              at sun.awt.X11.XChoicePeer$UnfurledChoice.placeOnScreen(Unknown Source)
              at sun.awt.X11.XChoicePeer.removeAll(Unknown Source)
              at java.awt.Choice.removeAll(Unknown Source)
              at sun.awt.X11.XFileDialogPeer.setDirectory(Unknown Source)
              at java.awt.FileDialog.setDirectory(Unknown Source)
              at javasoft.sqe.tests.api.java.awt.interactive.ComponentTests$ctestLnr.actionPerformed(ComponentTests.java:854)
              at java.awt.MenuItem.processActionEvent(Unknown Source)
              at java.awt.MenuItem.processEvent(Unknown Source)
              at java.awt.MenuComponent.dispatchEventImpl(Unknown Source)
              at java.awt.MenuComponent.dispatchEvent(Unknown Source)
              at java.awt.EventQueue.dispatchEvent(Unknown Source)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
              at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
              at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
              at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
              at java.awt.EventDispatchThread.run(Unknown Source)

      ====================================================================================
      Test's run command:

      $>/set/stt/jdk_promotions/JDK6.0/b43/binaries/linux-i586/jre1.6.0/bin/java -cp /set/stt/jck_promotions/6.0/beta/b04/binaries/JCK-runtime-60/classes javasoft.sqe.tests.api.java.awt.interactive.ComponentTests -TestCaseID ComponentTest0002

      =========================================================================
      I created code for reproducing : ComponentCut.java
      =========================================================================
      import java.awt.Button;
      import java.awt.Frame;
      import java.awt.Menu;
      import java.awt.MenuBar;
      import java.awt.MenuItem;
      import java.awt.FileDialog;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      public class ComponentCut {

      FileDialog openDialog;

      public static void main(String[] arg){
      ComponentCut cc = new ComponentCut();
      cc.run();
      }

      public void run(){

      Frame ctest = new Frame("Test 2");
      openDialog = new FileDialog(ctest,
      "Open File...",
      FileDialog.LOAD);
      MenuBar mb = new MenuBar();
      Menu m = new Menu("File");
      MenuItem mi;
      ctestLnr listener = new ctestLnr();
      m.add(mi = new MenuItem("Open..."));
      mi.addActionListener(listener);
      mb.add(m);
      ctest.setSize(300, 150);
      ctest.setMenuBar(mb);
      ctest.setVisible(true);
      }

      class ctestLnr implements ActionListener {
      public void actionPerformed(ActionEvent e) {
                  String name = e.getActionCommand();

      if (name.equals("Open...")) {

      openDialog.setDirectory("/tmp"); //Exception thrown here
      openDialog.setVisible(true);
      if(openDialog.getFile() != null) {
      System.out.println("OPEN: " +
      openDialog.getDirectory() +
      openDialog.getFile() + "\n");
      }
          }
      }
          }
      }

            dcherepanov Dmitry Cherepanov
            dtoporovsunw Denis Toporov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: