Debian Codegraph @

laf-widget/src/main/java/org/pushingpixels/lafwidget/contrib/blogofbug/swing/SwingBugUtilities.java

raw
1 /*
2 * SwingBugUtilities.java
3 *
4 * Created on March 30, 2007, 12:27 AM
5 *
6 * Copyright 2006-2007 Nigel Hughes
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the License at http://www.apache.org/
10 * licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
13 * governing permissions and limitations under the License.
14 */
15
16 package org.pushingpixels.lafwidget.contrib.blogofbug.swing;
17
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ActionListener;
20 import javax.swing.Timer;
21
22 /**
23 * Contains some utility methods applicable to any swing application.
24 *
25 * @author nigel
26 */
27 public class SwingBugUtilities {
28
29 /** Creates a new instance of SwingBugUtilities */
30 private SwingBugUtilities() {
31 }
32
33 /**
34 * Runs the supplied class after a certain period of time, the thread
35 * will be executed in the EDT.
36 *
37 * @param execute The runnable object whose method will be called after the
38 * specified delay
39 * @param after The delay in ms before the event will be called
40 */
41 public static void invokeAfter(final Runnable execute, int after){
42 Timer timer = new Timer(after,new ActionListener() {
43 @Override
44 public void actionPerformed(ActionEvent actionEvent) {
45 execute.run();
46 }
47 });
48
49 timer.setRepeats(false);
50 timer.start();
51 }
52 }