Search in sources :

Example 16 with Timer

use of javax.swing.Timer in project processdash by dtuma.

the class BackgroundTaskManager method doSuspend.

private void doSuspend(long delayMillis, long waitMillis) {
    SUSPEND_PERMISSION.checkPermission();
    BackgroundTaskExecutor bte;
    synchronized (this) {
        long newSuspendUntil = System.currentTimeMillis() + delayMillis;
        this.suspendUntil = Math.max(this.suspendUntil, newSuspendUntil);
        bte = currentTaskExecutor;
    }
    ActionListener taskRestarter = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            startExecutingTasks();
        }
    };
    Timer t = new Timer((int) delayMillis + 5000, taskRestarter);
    t.setRepeats(false);
    t.start();
    if (bte != null) {
        if (waitMillis > 0)
            bte.waitForTermination(waitMillis);
    }
}
Also used : ActionListener(java.awt.event.ActionListener) Timer(javax.swing.Timer) ActionEvent(java.awt.event.ActionEvent)

Example 17 with Timer

use of javax.swing.Timer in project vcell by virtualcell.

the class ServerManageConsole method getJFrameContentPane.

/**
 * Return the JFrameContentPane property value.
 * @return javax.swing.JPanel
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JPanel getJFrameContentPane() {
    if (ivjJFrameContentPane == null) {
        try {
            ivjJFrameContentPane = new javax.swing.JPanel();
            ivjJFrameContentPane.setName("JFrameContentPane");
            ivjJFrameContentPane.setLayout(new java.awt.BorderLayout());
            getJFrameContentPane().add(getTabbedPane(), "Center");
            JPanel panel = new javax.swing.JPanel();
            panel.setLayout(new FlowLayout(FlowLayout.LEFT));
            panel.add(getExitButton());
            panel.add(getRefreshButton(), getRefreshButton().getName());
            final JLabel timeLabel = new JLabel("      ");
            timeLabel.setFont(new Font(timeLabel.getFont().getName(), Font.BOLD, timeLabel.getFont().getSize()));
            Box box = Box.createHorizontalBox();
            box.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()));
            box.add(panel);
            box.add(Box.createHorizontalGlue());
            box.add(timeLabel);
            box.add(Box.createHorizontalGlue());
            box.add(getProgressBar());
            final DateFormat df = new SimpleDateFormat("HH:mm:ss    EEEE    MMM dd, yyyy");
            new Timer(1000, new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    timeLabel.setText(df.format(new Date()));
                }
            }).start();
            getJFrameContentPane().add(box, "North");
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    return ivjJFrameContentPane;
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) Font(java.awt.Font) Date(java.util.Date) Timer(javax.swing.Timer) ActionListener(java.awt.event.ActionListener) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) BorderLayout(java.awt.BorderLayout) SimpleDateFormat(java.text.SimpleDateFormat) JPanel(javax.swing.JPanel)

Example 18 with Timer

use of javax.swing.Timer in project opticus-project by MrXnight.

the class Animation method scroll.

/**
 * Méthode qui permet le scroll automatique du text
 */
public void scroll() {
    // On met un delai de 30 ms pour le scroll-auto
    int timerDelay = 30;
    running = true;
    // On créer un timer qui permet le scroll
    new Timer(timerDelay, new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // On place le curseur de la scroll bar à l'indice i et on incrémente
            scroll.getVerticalScrollBar().setValue(i);
            if (versLeBas) {
                i++;
            } else {
                i--;
            }
            if (i >= scroll.getVerticalScrollBar().getHeight() * 2.4 || i <= 0) {
                running = false;
                ((Timer) e.getSource()).stop();
            }
        }
    }).start();
}
Also used : Timer(javax.swing.Timer)

Example 19 with Timer

use of javax.swing.Timer in project cytoscape-impl by cytoscape.

the class NetworkViewContainer method init.

private void init() {
    setFocusable(true);
    setRequestFocusEnabled(true);
    final JPanel glassPane = new JPanel(null);
    getRootPane().setGlassPane(glassPane);
    glassPane.setOpaque(false);
    glassPane.setVisible(true);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(getVisualizationContainer(), BorderLayout.CENTER);
    getContentPane().add(getToolBar(), BorderLayout.SOUTH);
    setKeyBindings(this);
    setKeyBindings(getRootPane());
    updateTollBar();
    updateBirdsEyeViewPanel();
    glassPane.add(getBirdsEyeViewPanel());
    resizeTimer = new Timer(0, new ResizeActionListener());
    resizeTimer.setRepeats(false);
    resizeTimer.setCoalesce(true);
    resizeTimer.start();
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) Timer(javax.swing.Timer)

Example 20 with Timer

use of javax.swing.Timer in project cytoscape-impl by cytoscape.

the class NetworkViewMediator method handleEvent.

@Override
public void handleEvent(NetworkViewAboutToBeDestroyedEvent nvde) {
    final CyNetworkView view = nvde.getNetworkView();
    Timer timer = null;
    synchronized (lock) {
        timer = viewUpdateTimers.remove(view);
    }
    if (timer != null)
        timer.stop();
    removeView(view);
}
Also used : Timer(javax.swing.Timer) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

Timer (javax.swing.Timer)130 ActionEvent (java.awt.event.ActionEvent)66 ActionListener (java.awt.event.ActionListener)62 IOException (java.io.IOException)12 JPanel (javax.swing.JPanel)12 JLabel (javax.swing.JLabel)11 BorderLayout (java.awt.BorderLayout)9 Dimension (java.awt.Dimension)9 Point (java.awt.Point)9 Color (java.awt.Color)8 JCheckBox (javax.swing.JCheckBox)8 MouseEvent (java.awt.event.MouseEvent)7 JFrame (javax.swing.JFrame)7 MouseAdapter (java.awt.event.MouseAdapter)6 Window (java.awt.Window)5 JButton (javax.swing.JButton)5 JDialog (javax.swing.JDialog)5 JScrollPane (javax.swing.JScrollPane)5 File (java.io.File)4 Date (java.util.Date)4