本文整理了Java中javax.swing.Timer.start()
方法的一些代码示例,展示了Timer.start()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timer.start()
方法的具体详情如下:
包路径:javax.swing.Timer
类名称:Timer
方法名:start
暂无
代码示例来源:origin: plantuml/plantuml
private void startTimer() {
Log.info("Init done");
final Timer timer = new Timer(period, new ActionListener() {
public void actionPerformed(ActionEvent e) {
tick();
}
});
timer.setInitialDelay(0);
timer.start();
Log.info("Timer started");
}
代码示例来源:origin: stackoverflow.com
JFrame f = new JFrame("MarqueeTest");
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();
代码示例来源:origin: stackoverflow.com
run.setText(START);
} else {
timer.start();
run.setText(STOP);
btnPanel.add(run);
btnPanel.add(combo);
this.add(btnPanel, BorderLayout.SOUTH);
timer = new Timer(FAST, new ActionListener() {
timer.start();
代码示例来源:origin: net.sf.taverna.t2.core/workflowmodel-impl
/**
* Very simple UI!
*/
public void showMonitorFrame() {
final JTree tree = new AlwaysOpenJTree(monitorTree);
final JScrollPane jsp = new JScrollPane(tree);
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(jsp);
frame.pack();
frame.setVisible(true);
new javax.swing.Timer(500, new ActionListener() {
public void actionPerformed(ActionEvent ae) {
jsp.repaint();
}
}).start();
}
代码示例来源:origin: stackoverflow.com
final JFrame frame = new JFrame("table adjust example");
frame.add(createUI());
frame.pack();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
javax.swing.Timer timer = new javax.swing.Timer(3000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
timer.setRepeats(true);
timer.setCoalesce(true);
timer.start();
代码示例来源:origin: stackoverflow.com
final JFrame frame = new JFrame();
frame.setLayout(new FlowLayout());
frame.setMinimumSize(new Dimension(200, 200));
startButton.addActionListener(e -> timer.start());
frame.add(startButton);
frame.add(stopButton);
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.Timer;
public class TimerExample {
public static void main(String args[]) {
new JFrame().setVisible( true );
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
System.out.println( "expired" );
}
};
Timer timer = new Timer( 30000, actionListener );
timer.start();
}
}
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
final JPanel panel = new JPanel();
panel.setLayout(null);
final int size = 400;
javax.swing.Timer timer = new javax.swing.Timer(500, new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
JLabel lab = new JLabel("HERE");
lab.setLocation((int)(size * Math.random()), (int)(size * Math.random()));
lab.setSize(new Dimension(40,20));
panel.add(lab);
panel.repaint();
}
});
frame.add(panel);
frame.setSize(size, size);
frame.setVisible(true);
timer.start();
代码示例来源:origin: stackoverflow.com
private static final int RADIUS = 25;
private static final int FRAMES = 24;
private final Timer timer = new Timer(20, this);
private final Rectangle rect = new Rectangle();
private BufferedImage background;
JFrame f = new JFrame("AnimationTest");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(this);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
timer.start();
Dimension d = field.getPreferredSize();
field.setBounds(e.getX(), e.getY(), d.width, d.height);
add(field);
代码示例来源:origin: net.sf.taverna.t2/workflowmodel-impl
/**
* Very simple UI!
*/
public void showMonitorFrame() {
final JTree tree = new AlwaysOpenJTree(monitorTree);
final JScrollPane jsp = new JScrollPane(tree);
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(jsp);
frame.pack();
frame.setVisible(true);
new javax.swing.Timer(500, new ActionListener() {
public void actionPerformed(ActionEvent ae) {
jsp.repaint();
}
}).start();
}
代码示例来源:origin: apache/ignite
/**
* Default constructor.
*/
private HitRateMetricsSandbox() {
IgniteUtils.onGridStart();
JButton hitBtn = new JButton("Hit");
hitBtn.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
metrics.onHit();
}
});
new Timer(100, new ActionListener() {
@Override public void actionPerformed(ActionEvent evt) {
rateLb.setText(Double.toString(metrics.getRate()));
}
}).start();
setContentPane(createPanel(new JLabel("Hits in 5 seconds:"), rateLb, hitBtn));
setMinimumSize(new Dimension(300, 120));
}
代码示例来源:origin: stackoverflow.com
public class TimerDemo {
public static void main(String[] args) {
final int oneSecondDelay = 1000;
final JLabel label = new JLabel(Long.toString(System.currentTimeMillis()));
ActionListener task = new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
label.setText(Long.toString(System.currentTimeMillis()));
}
};
new javax.swing.Timer(oneSecondDelay, task).start();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new FlowLayout());
frame.add(label);
frame.pack();
frame.setVisible(true);
}
}
代码示例来源:origin: stackoverflow.com
@Override
public void run() {
JFrame frame = new JFrame( "RotatingIcon" );
JTabbedPane tabbedPane = new JTabbedPane( );
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();
delegateIcon.paintIcon(c, g2, x, y);
g2.setTransform(original);
rotatingTimer.start();
代码示例来源:origin: net.sf.taverna.t2/maelstrom-impl
/**
* Very simple UI!
*/
public void showMonitorFrame() {
final JTree tree = new AlwaysOpenJTree(monitorTree);
final JScrollPane jsp = new JScrollPane(tree);
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(jsp);
frame.pack();
frame.setVisible(true);
new javax.swing.Timer(500, new ActionListener() {
public void actionPerformed(ActionEvent ae) {
jsp.repaint();
}
}).start();
}
代码示例来源:origin: plantuml/plantuml
private void startTimer() {
Log.info("Init done");
final Timer timer = new Timer(10000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
tick();
}
});
timer.setInitialDelay(0);
timer.start();
Log.info("Timer started");
}
代码示例来源:origin: stackoverflow.com
private final Timer timer = new Timer(1000, this);
private final List<ButtonPanel> panels = new ArrayList<ButtonPanel>();
ButtonPanel bp = new ButtonPanel(i);
panels.add(bp);
this.add(bp);
this.add(new JButton("Button " + String.valueOf(i)));
JFrame f = new JFrame("ButtonTest");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ButtonTest bt = new ButtonTest();
f.add(bt);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
bt.timer.start();
代码示例来源:origin: org.apache.taverna.engine/taverna-workflowmodel-impl
/**
* Very simple UI!
*/
public void showMonitorFrame() {
final JTree tree = new AlwaysOpenJTree(monitorTree);
final JScrollPane jsp = new JScrollPane(tree);
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(jsp);
frame.pack();
frame.setVisible(true);
new javax.swing.Timer(500, new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
jsp.repaint();
}
}).start();
}
代码示例来源:origin: org.netbeans.api/org-openide-util
/** Impl of HierarchyListener, starts init job with delay when component shown,
* stops listening to asociated component it isn't showing anymore,
* calls cancel if desirable.
* @param evt hierarchy event
*/
@Override
public void hierarchyChanged(HierarchyEvent evt) {
final boolean hierachyChanged = (evt.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0;
LOG.log(Level.FINE, "Hierarchy Changed {0}", hierachyChanged);
if (hierachyChanged) {
boolean isShowing = comp4Init.isShowing();
if (timer == null && isShowing) {
timer = new Timer(20, this);
timer.setRepeats(false);
timer.start();
LOG.log(Level.FINE, "Timer started for {0}", comp4Init);
} else if (!isShowing) {
comp4Init.removeHierarchyListener(this);
LOG.log(Level.FINE, "Not showing, cancling for {0}", comp4Init);
cancel();
}
}
}
代码示例来源:origin: stackoverflow.com
private final Timer timer = new Timer(1000, this);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(this);
f.pack();
f.setVisible(true);
timer.start();
for (JLabel label : list) add(label);
this.validate();
代码示例来源:origin: stackoverflow.com
Timer timer = new Timer(40, listener);
timer.start();
JOptionPane.showMessageDialog(null, label);
内容来源于网络,如有侵权,请联系作者删除!