lombok-pg -

lombok
Annotation Type SwingInvokeLater


@Target(value=METHOD)
@Retention(value=SOURCE)
public @interface SwingInvokeLater

Wraps a bit of Swing pain.

With lombok:

 class SwingApp {
        private final JFrame frame = new JFrame();
 
        @SwingInvokeLater
        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 {
                        java.awt.EventQueue.invokeLater($startRunnable);
                }
        }
 }
 


lombok-pg -

Copyright © 2010-2011 Philipp Eichhorn, licensed under the MIT licence.