List of usage examples for javax.swing Timer setRepeats
public void setRepeats(boolean flag)
flag
is false
, instructs the Timer
to send only one action event to its listeners. From source file:storybook.SbApp.java
public void renameFile(final MainFrame mainFrame, File file) { trace("SbApp.renameFile(" + mainFrame.getName() + "," + file.getAbsolutePath() + ")"); try {//w ww . j a v a 2 s .c o m FileUtils.copyFile(mainFrame.getDbFile().getFile(), file); DbFile dbFile = new DbFile(file); OpenFileAction act = new OpenFileAction("", dbFile); act.actionPerformed(null); Timer t1 = new Timer(1000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mainFrame.close(); } }); t1.setRepeats(false); t1.start(); Timer t2 = new Timer(4000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mainFrame.getDbFile().getFile().delete(); } }); t2.setRepeats(false); t2.start(); } catch (IOException e) { error("SbApp.renameFile(" + mainFrame.getName() + "," + file.getName() + ")", e); } }
From source file:storybook.toolkit.swing.SwingUtil.java
/** * Flashes the given {@link Component} for 250 milliseconds. * * @param comp the component to flash/*w w w. ja v a 2s.c o m*/ */ public static void flashComponent(JComponent comp) { synchronized (flashIsRunning) { if (flashIsRunning) return; flashIsRunning = true; FlashThread flash = new FlashThread(comp); SwingUtilities.invokeLater(flash); FlashThread flash2 = new FlashThread(comp, true); Timer timer = new Timer(1000, flash2); timer.setRepeats(false); timer.start(); } }