Search in sources :

Example 1 with Timer

use of javax.swing.Timer in project jitsi by jitsi.

the class SingleWindowContainer method close.

/**
     * {@inheritDoc}
     *
     * The delay implemented by <tt>SingleWindowContainer</tt> is 5 seconds.
     */
public void close(CallPanel callPanel, boolean delay) {
    if (delay) {
        Timer timer = new Timer(5000, new CloseCallListener(callPanel));
        timer.setRepeats(false);
        timer.start();
    } else
        removeConversation(callPanel);
}
Also used : Timer(javax.swing.Timer)

Example 2 with Timer

use of javax.swing.Timer in project screenbird by adamhub.

the class RecorderPanel method startCountdown.

/**
     * Initiates countdown and prepares for screen capture. 
     */
private void startCountdown() {
    final Countdown[] countdown = new Countdown[1];
    countdownSec = 6;
    countdownTimer = new Timer(500, new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            countdownSec--;
            log("Counting: " + countdownSec);
            switch(countdownSec) {
                case 0:
                    countdownTimer.stop();
                    jLabel5.setText("Recording");
                    btnRecordNonRec.setText("Stop");
                    btnRecordRec.setText("Stop");
                    btnPlayPauseBackup.setText("");
                    btnPlayPauseBackup.setIcon(pauseIcon);
                    btnFinalizeBackup.setEnabled(true);
                    // Destroy the countdown window.
                    countdown[0].destroy();
                    try {
                        Thread.sleep(500);
                    } catch (Exception ee) {
                    }
                    startRecordState();
                    break;
                case 1:
                case 2:
                case 3:
                case 4:
                    btnPlayPauseBackup.setText(String.valueOf(countdownSec));
                    countdown[0].destroy();
                    countdown[0] = new Countdown(false, recorder);
                    countdown[0].setCount(countdownSec);
                    countdown[0].setVisible(true);
                    try {
                        SoundUtil.tone(880, 500, 0.15);
                    } catch (LineUnavailableException ee) {
                    }
                    break;
                case 5:
                    btnPlayPauseBackup.setText(String.valueOf(countdownSec));
                    // Hide drop box
                    if (captureBox != null) {
                        captureBox.setDragBoxVisible(false);
                    }
                    countdown[0] = new Countdown(false, recorder);
                    countdown[0].setCount(5);
                    countdown[0].setVisible(true);
                    try {
                        SoundUtil.tone(880, 500, 0.15);
                    } catch (LineUnavailableException ee) {
                    }
                    break;
            }
        }
    });
    countdownTimer.start();
}
Also used : Timer(javax.swing.Timer) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) LineUnavailableException(javax.sound.sampled.LineUnavailableException) Countdown(com.bixly.pastevid.screencap.components.capturebox.Countdown) MissingResourceException(java.util.MissingResourceException) FileNotFoundException(java.io.FileNotFoundException) LineUnavailableException(javax.sound.sampled.LineUnavailableException) IOException(java.io.IOException)

Example 3 with Timer

use of javax.swing.Timer in project screenbird by adamhub.

the class RecorderPanel method initResizeTask.

/**
     * Monitors the size of the recorder and adjusts it properly, depending
     * on whether the recorder panel is visible or the upload form is visible.
     * 
     * This does nothing on systems that support transparency.
     */
private void initResizeTask() {
    if (AWTUtilities.isTranslucencyCapable(((ScreenRecorder) this.jfRecorderPanel).getGraphicsConfiguration())) {
        log("Not doing resizing...");
        return;
    }
    final RecorderPanel recorderPanel = this;
    final Dimension recorderDimension = new Dimension(276, 62);
    final Dimension uploadDimension = jpUpload.getPreferredSize();
    final Dimension invisibleDimension = new Dimension(0, 0);
    TimerTask tt = new TimerTask() {

        @Override
        public void run() {
            boolean changed = false;
            if (recorderPanel.recorderPanelBG1.isVisible() && !recorderDimension.equals(recorderPanel.getSize())) {
                log("Resizing! " + recorderDimension + " " + ((JFrame) recorderPanel.jfRecorderPanel).getPreferredSize());
                recorderPanel.setPreferredSize(recorderDimension);
                recorderPanel.setMinimumSize(recorderDimension);
                recorderPanel.setMaximumSize(recorderDimension);
                recorderPanel.setSize(recorderDimension);
                changed = true;
            } else if (recorderPanel.jpUpload.isVisible() && !uploadDimension.equals(recorderPanel.getSize())) {
                log("Resizing! " + uploadDimension + " " + ((JFrame) recorderPanel.jfRecorderPanel).getPreferredSize());
                recorderPanel.setPreferredSize(uploadDimension);
                recorderPanel.setMinimumSize(uploadDimension);
                recorderPanel.setMaximumSize(uploadDimension);
                recorderPanel.setSize(uploadDimension);
                changed = true;
            } else if (!recorderPanel.jpUpload.isVisible() && !recorderPanel.recorderPanelBG1.isVisible() && !invisibleDimension.equals(recorderPanel.getSize())) {
                log("Resizing! " + uploadDimension + " " + ((JFrame) recorderPanel.jfRecorderPanel).getPreferredSize());
                recorderPanel.setPreferredSize(invisibleDimension);
                recorderPanel.setMinimumSize(invisibleDimension);
                recorderPanel.setMaximumSize(invisibleDimension);
                recorderPanel.setSize(invisibleDimension);
                changed = true;
            }
            if (changed) {
                ((ScreenRecorder) recorderPanel.jfRecorderPanel).controlPack();
                ((ScreenRecorder) recorderPanel.jfRecorderPanel).repaint();
                ((ScreenRecorder) recorderPanel.jfRecorderPanel).getContentPane().repaint();
                recorderPanel.repaint();
                recorderPanel.recorderPanelBG1.repaint();
            }
        }
    };
    java.util.Timer timer = new java.util.Timer();
    timer.scheduleAtFixedRate(tt, 0, 10);
}
Also used : TimerTask(java.util.TimerTask) Timer(javax.swing.Timer) JFrame(javax.swing.JFrame) Dimension(java.awt.Dimension)

Example 4 with Timer

use of javax.swing.Timer in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method handleEvent.

@Override
public void handleEvent(NetworkViewAboutToBeDestroyedEvent e) {
    final CyNetworkView netView = e.getNetworkView();
    Timer timer = filterTimers.remove(netView);
    if (timer != null)
        timer.stop();
    invokeOnEDT(() -> {
        getControlPanel().removeEnrichmentMapView(netView);
    });
}
Also used : Timer(javax.swing.Timer) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 5 with Timer

use of javax.swing.Timer in project intellij-community by JetBrains.

the class JBViewport method notify.

private static Notification notify(String message) {
    Notification notification = NOTIFICATION_GROUP.createNotification(message, NotificationType.INFORMATION);
    notification.notify(null);
    Timer timer = new Timer(NOTIFICATION_TIMEOUT, event -> notification.expire());
    timer.setRepeats(false);
    timer.start();
    return notification;
}
Also used : Timer(javax.swing.Timer) Notification(com.intellij.notification.Notification)

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