Search in sources :

Example 71 with Timer

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

the class TwoIndexTcsProgrammerFacade method programmingOpReply.

// get notified of the final result
// Note this assumes that there's only one phase to the operation
@Override
public void programmingOpReply(int value, int status) {
    if (log.isDebugEnabled()) {
        log.debug("notifyProgListenerEnd value " + value + " status " + status);
    }
    if (_usingProgrammer == null) {
        log.error("No listener to notify, reset and ignore");
        state = ProgState.NOTPROGRAMMING;
        return;
    }
    // Complete processing later so that WOWDecoder will go through a complete power on reset and not brown out between CV read/writes
    int interval = 150;
    ActionListener taskPerformer = new ActionListener() {

        final int myValue = value;

        final int myStatus = status;

        @Override
        public void actionPerformed(ActionEvent evt) {
            processProgrammingOpReply(myValue, myStatus);
        }
    };
    Timer t = new Timer(interval, taskPerformer);
    t.setRepeats(false);
    t.start();
}
Also used : ActionListener(java.awt.event.ActionListener) Timer(javax.swing.Timer) ActionEvent(java.awt.event.ActionEvent)

Example 72 with Timer

use of javax.swing.Timer in project jdk8u_jdk by JetBrains.

the class Test6559154 method run.

public void run() {
    Timer timer = new Timer(1000, this);
    timer.setRepeats(false);
    timer.start();
    JColorChooser chooser = new JColorChooser();
    setEnabledRecursive(chooser, false);
    this.dialog = new JDialog();
    this.dialog.add(chooser);
    this.dialog.setVisible(true);
}
Also used : Timer(javax.swing.Timer) JColorChooser(javax.swing.JColorChooser) JDialog(javax.swing.JDialog)

Example 73 with Timer

use of javax.swing.Timer in project jabref by JabRef.

the class MainTableSelectionListener method updatePreview.

private void updatePreview(final BibEntry toShow, final boolean changedPreview, int repeats) {
    if (workingOnPreview) {
        if (repeats > 0) {
            // We've already waited once. Give up on this selection.
            return;
        }
        Timer t = new Timer(50, actionEvent -> updatePreview(toShow, changedPreview, 1));
        t.setRepeats(false);
        t.start();
        return;
    }
    EventList<BibEntry> list = table.getSelected();
    // Check if the entry to preview is still selected:
    if ((list.size() != 1) || (list.get(0) != toShow)) {
        return;
    }
    final BasePanelMode mode = panel.getMode();
    workingOnPreview = true;
    SwingUtilities.invokeLater(() -> {
        preview.setEntry(toShow);
        // If nothing was already shown, set the preview and move the separator:
        if (changedPreview || (mode == BasePanelMode.SHOWING_NOTHING)) {
            panel.showPreview(preview);
            panel.adjustSplitter();
        }
        workingOnPreview = false;
    });
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) Timer(javax.swing.Timer) BasePanelMode(org.jabref.gui.BasePanelMode)

Example 74 with Timer

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

the class Diesel3Sound method newTimer.

protected Timer newTimer(long time, boolean repeat, ActionListener al) {
    // make sure the time is > zero
    time = Math.max(1, time);
    t = new Timer((int) time, al);
    t.setInitialDelay((int) time);
    t.setRepeats(repeat);
    return (t);
}
Also used : Timer(javax.swing.Timer)

Example 75 with Timer

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

the class VSDSound method newTimer.

protected Timer newTimer(int time, boolean repeat, ActionListener al) {
    // make sure the time is > zero
    time = Math.max(1, time);
    t = new Timer(time, al);
    t.setInitialDelay(time);
    t.setRepeats(repeat);
    return (t);
}
Also used : Timer(javax.swing.Timer)

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