1

I read tutorial in File Browser Gui , but if the strucutre folder changed, program cannot dynamic reload, how to create refresh/reload function in File Browser GUI ?
Here my uncomplete code

refreshPath = new JButton("Refresh");
refreshPath.addActionListener(new ActionListener(){
     public void actionPerformed(ActionEvent ae) {
        ....
     }
});
toolBar.add(refreshPath);
Community
  • 1
  • 1

1 Answers1

3
  • FileIO is low level and hard event for Java and Native OS too

  • there are basically two ways

    a) Watching a Directory for Changes for Java7, discussed here.

    b) use some of custom FileIO Watching (I can't suggest what's is better or not, maybe FileWatcher by Apache)

  • in both cases nothing will be notified Swing GUI, have to notify by using SwingWorker or Runnable#Thread

  • by using Runnable#Thread ins't there guarantee that output will be notifyied Event Dispatch Thread, have wrapping output to the Swing GUI to the invokeLater()

  • SwingWorker guarantee that, but for safer output you can to use invokeLater() too, we talking about 4th. short codelines moreover

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319