Home
Categories
Dictionary
Download
Project Details
Changes Log
Tutorials
FAQ
License

Time counting



By default the time taken by Actions is computed and shown in the application Message area. For example:
timecounting
Note that the counting of time is by default computed between:

More control on the time counting

In some cases (for example if you open a file chooser in the run() method) you may want to have more control on the way the time is counted. You can do that by using the following methods: For example:
   public void run() throws Exception {
      app.stopTime(this); // don't show the progress bar
      JFileChooser chooser = new JFileChooser("Open Image");
      chooser.setDialogTitle("Open Image");
      chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
      if (chooser.showOpenDialog(app.getApplicationWindow()) == JFileChooser.APPROVE_OPTION) {
        app.startTime(this); // show the progress bar and start to count
        File file = chooser.getSelectedFile();
        BufferedImage image = ImageIO.read(file);
        if (image == null) throw new Exception("Bad File type");
        JScrollPane pane = new JScrollPane(new ImagePanel(image));
        app.addTab(pane, image, file.getName());
     } else {
        app.noWriteMessages(); // will not write anything in the message area (in this case the file chooser has been cancelled)
     }
   }

Don't sdhow the time at all

If you don't want to show the time for actions at all, you can override the MDIApplication.writeTimeMessages() method. For example:
   @Override
   public boolean writeTimeMessages() {
      return false;
   }

See also


Categories: General | Swing

Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences