Example usage for javax.swing Timer Timer

List of usage examples for javax.swing Timer Timer

Introduction

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

Prototype

public Timer(int delay, ActionListener listener) 

Source Link

Document

Creates a Timer and initializes both the initial delay and between-event delay to delay milliseconds.

Usage

From source file:com.microsoft.alm.plugin.idea.common.ui.controls.HelpPanel.java

public HelpPanel() {
    // Create controls
    helpLabel = new JLabel();
    final IconPanel helpIcon = new IconPanel(Icons.Help);

    // Layout controls
    setLayout(new GridBagLayout());
    SwingHelper.addToGridBag(this, helpLabel, 0, 0, 1, 1, 0, JBUI.scale(4));
    SwingHelper.addToGridBag(this, helpIcon, 1, 0);

    this.addMouseListener(new MouseEventListener());

    showTooltipTimer = new Timer(INITIAL_DELAY, new ActionListener() {
        @Override//from   www  .j a  v  a 2s .c o m
        public void actionPerformed(final ActionEvent e) {
            IdeaHelper.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    showToolTip(true);
                }
            });
        }
    });
    showTooltipTimer.setInitialDelay(INITIAL_DELAY);
    showTooltipTimer.setRepeats(false);

    hideTooltipTimer = new Timer(DISMISS_DELAY, new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            IdeaHelper.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    hideToolTip(true);
                }
            });
        }
    });
    hideTooltipTimer.setInitialDelay(DISMISS_DELAY);
    hideTooltipTimer.setRepeats(false);
}

From source file:com.gmt2001.datastore.IniStore.java

private IniStore() {
    inifolder = LoadConfigReal("");

    t = new Timer((int) saveinterval, this);
    t2 = new Timer(1, this);

    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());

    t.start();//from w w  w . ja  va2 s  .com
}

From source file:TapTapTap.java

public void createUI() {
    JFrame f = new JFrame("TapTapTap");

    final WaitLayerUI layerUI = new WaitLayerUI();
    JPanel panel = createPanel();
    JLayer<JPanel> jlayer = new JLayer<JPanel>(panel, layerUI);

    final Timer stopper = new Timer(4000, new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            layerUI.stop();/* w w w  .j  a v a  2  s  .  co  m*/
        }
    });
    stopper.setRepeats(false);

    mOrderButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            layerUI.start();
            if (!stopper.isRunning()) {
                stopper.start();
            }
        }
    });

    f.add(jlayer);

    f.setSize(300, 200);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}

From source file:ColorDifference.java

/** Creates a new instance of ColorDifference */
public ColorDifference() {
    Timer timer = new Timer(1000, this);
    timer.start();/*from  w  w w  .  j  a  v a2 s.c om*/
    setPreferredSize(new Dimension(300, 200));
}

From source file:subterranean.crimson.server.graphics.graphs.LineChart.java

public LineChart() {

    super(new BorderLayout());

    final TimeSeriesCollection dataset = new TimeSeriesCollection(this.s1);
    final JFreeChart chart = createChart(dataset);

    Timer timer = new Timer(900, this);
    timer.setInitialDelay(0);//from  www .  ja v  a  2s  . c o m

    // Sets background color of chart
    chart.setBackgroundPaint(Color.LIGHT_GRAY);

    // Created Chartpanel for chart area
    final ChartPanel chartPanel = new ChartPanel(chart);

    // Added chartpanel to main panel
    add(chartPanel);

    timer.start();

}

From source file:org.csml.tommo.sugar.modules.heatmap.InteractiveHeatmapDialog.java

public InteractiveHeatmapDialog(int row, int col, ResultsTable table) {
    super(SugarApplication.getApplication());
    initData(row, col, table);/*from  ww  w .  j  a  va2  s  . co  m*/
    timer = new Timer(1000, this);

    List<TileBPCoordinates> tileBPCoordinateList = table.getTileBPCoordinateList(row, col);
    int colSpan = col == table.getColumnCount() - 1 ? 1 : 2;
    int rowSpan = tileBPCoordinateList.size() / colSpan;
    centerPanel = new JPanel(new GridLayout(rowSpan, colSpan));
    JPanel buttonsPanel = createButtonsPanel();
    setLayout(new BorderLayout());
    rebuild();
    add(centerPanel, BorderLayout.CENTER);
    add(buttonsPanel, BorderLayout.SOUTH);
    setLocation(400, 350);
    setSize(250 * colSpan, 250 * rowSpan);
}

From source file:ftpclientgui.MainWindow.java

private void init() {
    this.labTime.setText(DateFormat.getTimeInstance().format(new Date()));
    this.labStatus.setText("Not logged in.");
    this.dirList.addSelectionListener(this);
    tmr = new Timer(950, this);
    tmr.start();//  w w  w .  java  2 s.  co m
}

From source file:gsn.wrappers.SystemTime.java

public boolean initialize() {
    AddressBean addressBean = getActiveAddressBean();
    //  TODO: negative values?
    timer = new Timer(addressBean.getPredicateValueAsInt(CLOCK_PERIOD_KEY, DEFAULT_CLOCK_PERIODS), this);
    maximumDelay = addressBean.getPredicateValueAsInt(MAX_DELAY_KEY, DEFAULT_MAX_DELAY);
    if (maximumDelay > 0) {
        streamElementBuffer = SynchronizedBuffer.decorate(new UnboundedFifoBuffer());
        delayPostingElements = true;//from  ww w. ja v a  2s .c o m
        if (timer.getDelay() < maximumDelay)
            logger.warn(
                    "Maximum delay is greater than element production interval. Running for a long time may lead to an OutOfMemoryException");
    }
    return true;
}

From source file:eu.dety.burp.joseph.attacks.bleichenbacher_pkcs1.gui.BleichenbacherPkcs1DecryptionAttackPanel.java

/**
 * Creates new form BleichenbacherPkcs1DecryptionAttackPanel
 *//*w  ww  .j a  v  a2  s  .  c o m*/
public BleichenbacherPkcs1DecryptionAttackPanel(BleichenbacherPkcs1 reference) {
    this.reference = reference;

    initComponents();

    setVisibilityStatusComponents(false);
    jScrollPane2.setVisible(false);
    jScrollPane3.setVisible(false);
    cekFormatHex.setVisible(false);
    cekFormatB64.setVisible(false);
    resultKeyLabel.setVisible(false);
    resultKeyLabel.setVisible(false);
    resultKeyValue.setVisible(false);
    resultContentLabel.setVisible(false);
    resultContentValue.setVisible(false);

    attackTimer = new Timer(1000, taskPerformer);
}

From source file:net.sf.dvstar.transmission.dialogs.StatsDialog.java

/** Creates new form StatsDialog */
public StatsDialog(TransmissionView parent, TransmissionWebClient webClient, boolean modal) {
    super(parent.getFrame(), modal);
    this.webClient = webClient;
    this.parent = parent;
    initComponents();//from  w ww  .ja  v a 2 s .co m
    int messageTimeout = 5000;

    new SwingWorker() {

        @Override
        protected Object doInBackground() throws Exception {
            fillData();
            return null;
        }
    }.execute();

    updaterTimer = new Timer(messageTimeout, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new SwingWorker() {
                @Override
                protected Object doInBackground() throws Exception {
                    updaterTimer.stop();
                    fillData();
                    updaterTimer.start();
                    return null;
                }
            }.execute();
        }
    });

    updaterTimer.setRepeats(true);
    updaterTimer.start();
}