下面列出了javax.swing.Timer#isRunning ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void layoutContainer(Container parent) {
JComponent jc = (JComponent) parent;
install(jc);
Timer timer = (Timer) jc.getClientProperty(PROPERTY_TIMER);
Boolean layoutImmediately = (Boolean) jc
.getClientProperty(PROPERTY_LAYOUT_IMMEDIATELY);
if (layoutImmediately == null)
layoutImmediately = false;
if (layoutImmediately) {
layoutContainerImmediately(jc);
if (parent.isShowing())
jc.putClientProperty(PROPERTY_LAYOUT_IMMEDIATELY, false);
} else {
if (!timer.isRunning())
timer.start();
}
}
private void startTimer() {
Timer t = getTimer();
if (t.isRunning()) {
return;
}
repaint();
t.setDelay(400);
t.start();
}
private void startTimer() {
Timer t = getTimer();
if (t.isRunning()) {
return;
}
repaint();
t.setDelay(400);
t.start();
}
private String initialize() {
int defaultRefresh = GlobalPreferences.sharedInstance().getMonitoredDataPoll() * 1000;
processor = getTimer();
heapTimer = new Timer(defaultRefresh, new ActionListener() {
public void actionPerformed(ActionEvent e) {
heapRefresher.refresh();
}
});
heapRefresher = new Refresher() {
public final boolean checkRefresh() {
if (!heapTimer.isRunning()) return false;
return heapView.isShowing();
}
public final void doRefresh() {
if (heapView.isShowing()) {
doRefreshImpl(heapTimer, heapView);
}
}
public final void setRefreshRate(int refreshRate) {
heapTimer.setDelay(refreshRate);
heapTimer.setInitialDelay(refreshRate);
heapTimer.restart();
}
public final int getRefreshRate() {
return heapTimer.getDelay();
}
};
return null;
}
private Registration timerReg(final Timer timer) {
return new Registration() {
@Override
protected void doRemove() {
if (timer.isRunning()) {
timer.stop();
}
}
};
}
public static void flashRed(final Component component) {
synchronized(components) {
Timer oldTimer = components.get(component);
if(oldTimer != null && oldTimer.isRunning())
oldTimer.stop();
final Timer timer = new FadeTimer(component);
timer.start();
components.put(component, timer);
}
}