1 Reply Latest reply on Apr 5, 2007 4:24 PM by 807596

    Timely JFileChooser

      When I pressed a JButton to display a JFileChooser, it takes longer sometimes than others.

      There is enough of a delay that it makes me question whether I pressed the button or not.

      I changed the cursor to a wait cursor, which I release after creating the JFileChoser, however that has issues.

      I was trying to give some feedback that the button was pressed and to please wait.
      public void actionPerformed(ActionEvent e)
           if (e.getSource() == browserButton())
                JFileChooser chooser = new JFileChooser(....);   
                // do whatever work with the selected directory/file....
      Is there another workaround for this...

      This works, but setting a busy cursor takes an EventQueue slot -- and perhaps, I'm not sure if, it also adds xx time to the JFileChooser appearing.

      WIth that, the cursor seems to remain a busy cursor after the chooser appears -- until you move the mouse.
        • 1. Re: Timely JFileChooser
          I found some documentation on this solution ... but I'm not sure if it's a good work around.

          Advice... ??

          What I found was creating the JFileChoose in a SwingWorker and calling the get() method on the SwingWorker to return the JFileChooser.
          public void displayJFileChooser()
               SwingWorker createJFileChooser = new SwingWorker()
                    public Object construct()
                         return new JFileChooser();
               JFileChooser chooser = createJFileChooser.get();
          Any advice ??

          I have a UI that is responding very slow to calls to JFileChooser and JDialogs ...