本文整理汇总了Java中javax.swing.Timer.restart方法的典型用法代码示例。如果您正苦于以下问题:Java Timer.restart方法的具体用法?Java Timer.restart怎么用?Java Timer.restart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.Timer
的用法示例。
在下文中一共展示了Timer.restart方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TtyrecSource
import javax.swing.Timer; //导入方法依赖的package包/类
/**
* Creates the ttyrec source. This should be overriden in implementing
* classes to take arguments that specify things like the file or
* network address to read the bytestream from. This also creates some
* default analyzers and decoders, but leaves them paused by default.
*/
public TtyrecSource() {
super("Ttyrec Source");
rec = new Ttyrec();
bytestream = new ByteChunkList();
backportAnalyze = null;
backportDecode = null;
analysisListeners = new HashSet<>();
decodeListeners = new HashSet<>();
readListeners = new HashSet<>();
listenerTimer = new Timer(100, new ActionListener() {
public void actionPerformed(ActionEvent e) {
firePendingEvents();
}
});
listenerTimer.restart();
// The analyzer must be created before the decoder.
// The analyzer starts with the most obvious-to-reject format (GZIP),
// then tries the other formats in turn.
leadingEdgeAnalyze =
new TtyrecAnalyzer(this, 1, TtyrecAnalyzer.InputFormat.GZIP);
// The decoder starts by trying 24x80, expanding if necessary.
leadingEdgeDecode = new TtyrecDecoder(this, 2, 24, 80);
leadingEdgeAnalyze.start();
leadingEdgeDecode.start();
leadingEdgeDecode.setPriority(MIN_PRIORITY);
nextSequenceNumber = 3;
}
示例2: showTip
import javax.swing.Timer; //导入方法依赖的package包/类
/**
* Show a tool tip.
*
* @param tipText the tool tip text
* @param pt the pixel position over which to show the tip
*/
public void showTip(String tipText, Point pt) {
if (getRootPane() == null)
return;
// draw in glass pane to appear on top of other components
if (glassPane == null) {
getRootPane().setGlassPane(glassPane = new JPanel());
glassPane.setOpaque(false);
glassPane.setLayout(null); // will control layout manually
glassPane.add(tip = new JToolTip());
tipTimer = new Timer(TIP_DELAY, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
glassPane.setVisible(false);
}
});
tipTimer.setRepeats(false);
}
if (tipText == null)
return;
// set tip text to identify current origin of pannable view
tip.setTipText(tipText);
// position tip to appear at upper left corner of viewport
tip.setLocation(SwingUtilities.convertPoint(this, pt, glassPane));
tip.setSize(tip.getPreferredSize());
// show glass pane (it contains tip)
glassPane.setVisible(true);
glassPane.repaint();
// this timer will hide the glass pane after a short delay
tipTimer.restart();
}