|
lombok-pg - | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||
@Target(value=METHOD) @Retention(value=SOURCE) public @interface SwingInvokeAndWait
Wraps a bit of Swing pain.
With lombok:
class SwingApp {
private final JFrame frame = new JFrame();
@SwingInvokeAndWait
void start() throws Exception {
frame.setTitle("SwingApp");
frame.setVisible(true);
}
}
Vanilla Java:
class SwingApp {
private final JFrame frame = new JFrame();
void start() throws Exception {
final java.lang.Runnable $startRunnable = new java.lang.Runnable() {
public void run() {
frame.setTitle("SwingApp");
frame.setVisible(true);
}
};
if (java.awt.EventQueue.isDispatchThread()) {
$startRunnable();
} else {
try {
java.awt.EventQueue.invokeAndWait($startRunnable);
} catch (java.lang.InterruptedException $ex1) {
} catch (java.lang.reflect.InvocationTargetException $ex2) {
final java.lang.Throwable $cause = $ex2.getCause();
if ($cause instanceof FileNotFoundException) throw (FileNotFoundException) $cause;
if ($cause != null) throw new java.lang.RuntimeException($cause);
}
}
}
}
|
lombok-pg - | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||