Java Code Examples for javax.swing.Timer#isRunning()

The following examples show how to use javax.swing.Timer#isRunning() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimatedLayout.java    From pumpernickel with MIT License 6 votes vote down vote up
@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();
	}
}
 
Example 2
Source File: TabControlButtonFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void startTimer() {
    Timer t = getTimer();
    if (t.isRunning()) {
        return;
    }
    repaint();
    t.setDelay(400);
    t.start();
}
 
Example 3
Source File: ButtonFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void startTimer() {
    Timer t = getTimer();
    if (t.isRunning()) {
        return;
    }
    repaint();
    t.setDelay(400);
    t.start();
}
 
Example 4
Source File: MemorySamplerSupport.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: AwtEventDispatchThread.java    From mapper with Apache License 2.0 5 votes vote down vote up
private Registration timerReg(final Timer timer) {
  return new Registration() {
    @Override
    protected void doRemove() {
      if (timer.isRunning()) {
        timer.stop();
      }
    }
  };
}
 
Example 6
Source File: Util.java    From DarkBot with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
	}
}