f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String s = "Tomorrow, and tomorrow, and tomorrow, " + "creeps in this petty pace from day to day, " + "sound and fury signifying nothing."; MarqueePanel mp = new MarqueePanel(s, 32); f.add(mp); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); mp.start(); private final Timer timer = new Timer(1000 / RATE, this); private final JLabel label = new JLabel(); private final String s; label.setFont(new Font("Serif", Font.ITALIC, 36)); label.setText(sb.toString()); this.add(label); timer.start(); timer.stop();
private void beginSend() { // Timer for updating duration labels. ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { try { setText(String.format(SEND_FORMAT, backend.getNumSentRows(), backend.getNumRows(), Utils.formattedMillis(backend.getSendDuration()), Utils.formattedMillis(backend.getSendRemainingDuration()))); } catch (Exception e) { e.printStackTrace(); } } }); } }; if (timer != null){ timer.stop(); } timer = new Timer(1000, actionListener); try { timer.start(); } catch (Exception e) { timer.stop(); GUIHelpers.displayErrorDialog(e.getMessage()); } }
/** * Creates new form DraftPanel */ public DraftPanel() { initComponents(); draftBooster.setOpaque(false); draftPicks.setSortSetting(SortSettingDraft.getInstance()); draftPicks.setOpaque(false); popupMenuPickedArea = new JPopupMenu(); addPopupMenuPickArea(); this.add(popupMenuPickedArea); popupMenuCardPanel = new JPopupMenu(); addPopupMenuCardPanel(); this.add(popupMenuCardPanel); draftLeftPane.setOpaque(false); countdown = new Timer(1000, e -> { if (--timeout > 0) { setTimeout(timeout); } else { setTimeout(0); countdown.stop(); } } ); }
jSplitPane1.setOpaque(false); restoreDividerLocationsAndDeckAreaSettings(); countdown = new javax.swing.Timer(1000, e -> { if (--timeout > 0) { countdown.stop(); removeDeckEditor();
tabbedPane.addTab( "Searching", new RotatingIcon( new ImageIcon( "resources/images/progress-indeterminate.png" ), tabbedPane ), new JLabel( new ImageIcon( "resources/images/rotatingIcon.gif" ) ) ); frame.getContentPane().add( tabbedPane ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.pack(); frame.setVisible( true ); private RotatingIcon( Icon icon, final JComponent component ) { delegateIcon = icon; rotatingTimer = new Timer( 100, new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { rotatingTimer.start(); rotatingTimer.stop(); Graphics2D g2 = (Graphics2D )g.create(); int cWidth = delegateIcon.getIconWidth() / 2; delegateIcon.paintIcon(c, g2, x, y); g2.setTransform(original); rotatingTimer.start();
if (timer != null){ timer.stop(); } timer = new Timer(1000, actionListener); this.backend.send(); this.resetSentRowLabels(backend.getNumRows()); timer.start(); } catch (Exception e) { timer.stop(); logger.log(Level.INFO, "Exception in sendButtonActionPerformed.", e); displayErrorDialog(e.getMessage());
setDefaultCloseOperation(EXIT_ON_CLOSE); contentPane.add(label, BorderLayout.CENTER); contentPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); pack(); timer.stop(); label.setText("The time is up!"); timer = new Timer(delay, action); timer.setInitialDelay(0); timer.start(); setVisible(true);
public class example extends JFrame implements ActionListener{ javax.swing.Timer timer = new javax.swing.Timer(1000, this); int c = 10; public example(){ timer.start(); initComponents(); // this is auto generated when creating JFrame @Override public void actionPerformed(ActionEvent e) { jLabel1.setText(""+c--); if (c == -1) { timer.stop(); } } }
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setResizable(false); window.getContentPane().add(new MyCanvas()); window.pack(); window.setVisible(true); lines = new ArrayList<>(); timer = new Timer(75, new ActionListener() { public void actionPerformed(ActionEvent e) { if (rotate < -50) { ((Timer) e.getSource()).stop(); } else { lines.add(new Line(x1, rotate)); start.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { timer.start(); add(start);
getRootPane().setGlassPane(new WaitPanel()); getRootPane().getGlassPane().setVisible(true); int delay = 4 * 1000; // 4 second delay new javax.swing.Timer(delay, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getRootPane().getGlassPane().setVisible(false); ((javax.swing.Timer) e).stop(); } }).start();
javax.swing.Timer swingTimer = new javax.swing.Timer(500, new ActionListener() { public void actionPerformed(ActionEvent evt) { if (seconds > 0) { //... } else { ((javax.swing.Timer)evt.getSource()).stop(); //... } } });