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);
}
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();
}
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);
}
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);
});
}
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;
}
Aggregations