Example usage for javax.swing Timer setRepeats

List of usage examples for javax.swing Timer setRepeats

Introduction

In this page you can find the example usage for javax.swing Timer setRepeats.

Prototype

public void setRepeats(boolean flag) 

Source Link

Document

If flag is false, instructs the Timer to send only one action event to its listeners.

Usage

From source file:org.datacleaner.windows.AnalysisJobBuilderWindowImpl.java

private void updateLeftPanelVisibility(boolean show) {
    if (show) {/* w  w  w.ja  v a  2  s  .c  om*/
        _leftPanel.setVisible(true);
        if (_leftPanel.isCollapsed()) {
            _leftPanel.setCollapsed(false);
        }
    } else {
        if (!_leftPanel.isCollapsed()) {
            _leftPanel.setCollapsed(true);
        }
        final Timer timer = new Timer(500, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (_leftPanel.isCollapsed()) {
                    _leftPanel.setVisible(false);
                }
            }
        });
        timer.setRepeats(false);
        timer.start();
    }
}

From source file:org.dishevelled.brainstorm.BrainStorm.java

/** {@inheritDoc} */
public void run() {
    JFrame f = new JFrame("Brain storm");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add("Center", this);
    f.setResizable(false);//from   www  .  j  a v  a 2s .co m
    f.setUndecorated(true);
    // hide cursor on linux and windows platforms
    f.setCursor(hiddenCursor);
    GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(f);
    f.validate();

    SwingUtilities.invokeLater(new Runnable() {
        /** {@inheritDoc} */
        public void run() {
            calculatePlaceholderSize();
            calculateTextAreaSize();
            validate();
            textArea.scrollRectToVisible(
                    new Rectangle(0, textArea.getHeight() - 1, textArea.getWidth(), textArea.getHeight()));
        }
    });

    // save every five minutes
    Timer t = new Timer(5 * 60 * 1000, new ActionListener() {
        /** {@inheritDoc} */
        public void actionPerformed(final ActionEvent event) {
            save();
        }
    });
    t.setRepeats(true);
    t.start();
}

From source file:org.domainmath.gui.MainFrame.java

private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
    MainFrame.octavePanel.evaluate("pkg load all;");
    String f = System.getProperty("user.dir") + File.separator + "cache" + File.separator + "pkg_list.xml";
    MainFrame.octavePanel.evaluate("DomainMath_PkgContents('" + f + "');");

    PkgDocFrame pkgDocFrame = new PkgDocFrame(this);
    pkgDocFrame.setLocationRelativeTo(this);
    this.setCursor(new Cursor(Cursor.WAIT_CURSOR));

    ActionListener taskPerformer = (ActionEvent evt1) -> {
        pkgDocFrame.setVisible(true);/*  w  ww . jav  a2 s .co  m*/
    };
    javax.swing.Timer t = new javax.swing.Timer(1200, taskPerformer);
    t.setRepeats(false);
    t.start();
    this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}

From source file:org.eobjects.datacleaner.windows.AnalysisJobBuilderWindowImpl.java

private void displayDatastoreSelection() {
    if (isShowing()) {
        if (_datastore == null) {
            if (!_leftPanel.isCollapsed()) {
                _leftPanel.setCollapsed(true);
            }//from  www .j  a va2 s  .c o m
            Timer timer = new Timer(500, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    _leftPanel.setVisible(false);
                }
            });
            timer.setRepeats(false);
            timer.start();

            _sourceColumnsPanel.setVisible(false);
            _datastoreListPanelRef.get().setVisible(true);
            _datastoreListPanelRef.get().requestSearchFieldFocus();
        }
    }
}

From source file:org.exist.launcher.Launcher.java

public Launcher(final String[] args) {
    if (SystemTray.isSupported()) {
        tray = SystemTray.getSystemTray();
    }//from ww  w  . j ava  2 s.  c  o m

    captureConsole();

    this.jettyConfig = getJettyConfig();
    final Optional<Path> eXistHome = ConfigurationHelper.getExistHome();
    final Path wrapperConfig;
    if (eXistHome.isPresent()) {
        wrapperConfig = eXistHome.get().resolve("tools/yajsw/conf/wrapper.conf");
    } else {
        wrapperConfig = Paths.get("tools/yajsw/conf/wrapper.conf");
    }

    wrapperProperties = new Properties();
    wrapperProperties.setProperty("wrapper.working.dir", eXistHome.orElse(Paths.get(".")).toString());
    wrapperProperties.setProperty("wrapper.config", wrapperConfig.toString());

    System.setProperty("wrapper.config", wrapperConfig.toString());

    installedAsService();

    boolean initSystemTray = true;
    if (isSystemTraySupported()) {
        initSystemTray = initSystemTray();
    }

    configDialog = new ConfigurationDialog(this::shutdown);

    splash = new SplashScreen(this);
    splash.addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent windowEvent) {
            setServiceState();
            if (runningAsService.isPresent()) {
                splash.setStatus("eXist-db is already installed as service! Attaching to it ...");
                final Timer timer = new Timer(3000, (event) -> splash.setVisible(false));
                timer.setRepeats(false);
                timer.start();
            } else {
                if (ConfigurationUtility.isFirstStart()) {
                    splash.setVisible(false);
                    configDialog.open(true);
                    configDialog.requestFocus();
                } else {
                    startJetty();
                }
            }
        }
    });

    final boolean systemTrayReady = tray != null && initSystemTray && tray.getTrayIcons().length > 0;

    SwingUtilities.invokeLater(() -> utilityPanel = new UtilityPanel(Launcher.this, systemTrayReady));
}

From source file:org.freeplane.main.application.MapViewDockingWindows.java

public void focusMapViewLater(final MapView mapView) {
    Timer timer = new Timer(40, new ActionListener() {
        int retryCount = 5;

        public void actionPerformed(final ActionEvent event) {
            final Timer eventTimer = (Timer) event.getSource();
            focusMapLater(mapView, eventTimer);
        }//  w  w  w  . j a v a2 s . c o  m

        private void focusMapLater(final MapView mapView, final Timer eventTimer) {
            if (mapView.isShowing()
                    && Controller.getCurrentController().getMapViewManager().getMapViewComponent() == mapView) {
                final NodeView selected = mapView.getSelected();
                if (selected != null) {
                    final Frame frame = JOptionPane.getFrameForComponent(mapView);
                    if (frame.isFocused())
                        selected.requestFocusInWindow();
                    else
                        frame.addWindowFocusListener(new WindowAdapter() {
                            @Override
                            public void windowGainedFocus(WindowEvent e) {
                                frame.removeWindowFocusListener(this);
                                selected.requestFocusInWindow();
                                retryCount = 2;
                                eventTimer.start();
                            }
                        });
                }
            }
            if (retryCount > 1) {
                retryCount--;
                eventTimer.start();
            }
        }
    });
    timer.setRepeats(false);
    timer.start();
}

From source file:org.tinymediamanager.ui.MainWindow.java

private void checkForUpdate() {
    try {//from w  w  w .j  a  v a2  s  . c o  m
        final UpdaterTask updateWorker = new UpdaterTask();

        updateWorker.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if ("state".equals(evt.getPropertyName()) && evt.getNewValue() == StateValue.DONE) {
                    try {
                        boolean update = updateWorker.get();
                        LOGGER.debug("update result was: " + update);
                        if (update) {

                            // we might need this somewhen...
                            if (updateWorker.isForcedUpdate()) {
                                LOGGER.info("Updating (forced)...");
                                closeTmmAndStart(Utils.getPBforTMMupdate());
                                return;
                            }

                            // show whatsnewdialog with the option to update
                            if (StringUtils.isNotBlank(updateWorker.getChangelog())) {
                                UpdateDialog dialog = new UpdateDialog(updateWorker.getChangelog());
                                dialog.setVisible(true);
                            } else {
                                // do the update without changelog popup

                                int answer = JOptionPane.showConfirmDialog(null,
                                        BUNDLE.getString("tmm.update.message"),
                                        BUNDLE.getString("tmm.update.title"), JOptionPane.YES_NO_OPTION);
                                if (answer == JOptionPane.OK_OPTION) {
                                    LOGGER.info("Updating...");

                                    // spawn getdown and exit TMM
                                    closeTmmAndStart(Utils.getPBforTMMupdate());
                                }
                            }
                        }
                    } catch (Exception e) {
                        LOGGER.error("Update task failed!" + e.getMessage());
                    }
                }
            }
        });

        // update task start a few secs after GUI...
        Timer timer = new Timer(5000, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                updateWorker.execute();
            }
        });
        timer.setRepeats(false);
        timer.start();
    } catch (Exception e) {
        LOGGER.error("Update task failed!" + e.getMessage());
    }
}

From source file:org.trzcinka.intellitrac.view.toolwindow.tickets.ticket_editor.BaseTicketEditorForm.java

protected final void showDoneLabel() {
    final String lastText = submitChangesButton.getText();
    submitChangesButton.setText(bundle.getString("tool_window.tickets.ticket_editor.submit_changes.done"));
    int delay = IntelliTracConfiguration.getInstance().getConfiguration().getInt("submit_button_done_delay");
    Timer t = new Timer(delay, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            submitChangesButton.setText(lastText);
        }/*from   ww  w.  j ava2s. co  m*/
    });
    t.setRepeats(false);
    t.start();

}

From source file:pl.otros.logview.api.gui.LogViewPanelWrapper.java

private void createReadingProgressBar() {
    progressBar = new JProgressBar(0, 100);
    progressBar.setStringPainted(true);/*from w w  w.  j  a  v  a 2s.  c  o  m*/
    progressBar.setString("Processed ? of ? [?%]");
    final Timer t = new Timer(500, e -> {
        LOGGER.trace("Updating reading progress");
        final LoadingDetails loadingDetails = logLoader.getLoadingDetails(dataTableModel);
        final List<LogLoadingSession> logLoadingSessions = loadingDetails.getLogLoadingSessions();
        final List<LoadStatistic> statistics = logLoadingSessions.stream().map(logLoader::getLoadStatistic)
                .collect(Collectors.toList());
        final Long position = statistics.stream().collect(Collectors.summingLong(LoadStatistic::getPosition));
        final Long total = statistics.stream().collect(Collectors.summingLong(LoadStatistic::getTotal));
        final float percent = (100f) * ((float) position / total);
        progressBar.setValue((int) percent);
        final String msg = String.format("Processed %s of %s [%.2f%%]",
                FileSize.convertToStringRepresentation(position), FileSize.convertToStringRepresentation(total),
                percent);
        LOGGER.trace("Updating progress bar with message {}", msg);
        progressBar.setString(msg);

        final String tooltip = "<HTML>" + statistics.stream()
                .map(s -> String.format("Processed %s of %s [%.2f%%]  - %s",
                        FileSize.convertToStringRepresentation(s.getPosition()),
                        FileSize.convertToStringRepresentation(s.getTotal()), s.getPercent(),
                        s.getSource().stringForm()))
                .collect(Collectors.joining("<BR/>")) + "</HTML>";
        progressBar.setToolTipText(tooltip);
    });
    t.setRepeats(true);
    t.setInitialDelay(1000);
    t.start();
    timer = Optional.of(t);
}

From source file:storybook.action.ActionHandler.java

public void handleFileSave() {//new OK
    WaitDialog dlg = new WaitDialog(mainFrame, I18N.getMsg("msg.file.saving"));
    Timer timer = new Timer(500, new DisposeDialogAction(dlg));
    timer.setRepeats(false);
    timer.start();/*from   w w w.  j av a 2 s  .com*/
    SwingUtil.showModalDialog(dlg, mainFrame);
}