You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/05/01 16:31:09 UTC

svn commit: r770691 - /incubator/pivot/trunk/wtk/src/pivot/wtk/DesktopApplicationContext.java

Author: tvolkert
Date: Fri May  1 14:31:09 2009
New Revision: 770691

URL: http://svn.apache.org/viewvc?rev=770691&view=rev
Log:
Added helper main() method in DesktopApplicationContext

Modified:
    incubator/pivot/trunk/wtk/src/pivot/wtk/DesktopApplicationContext.java

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/DesktopApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/DesktopApplicationContext.java?rev=770691&r1=770690&r2=770691&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/DesktopApplicationContext.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/DesktopApplicationContext.java Fri May  1 14:31:09 2009
@@ -172,6 +172,26 @@
         System.exit(0);
     }
 
+    /**
+     * Utility method to make it easier to define main() entry-points in applications.
+     * <p>
+     * Then your main class looks like:
+     * <p>
+     * <pre>
+     *     public class MyApp implements Application {
+     *         public static void main(String[] args) throws Exception {
+     *             DesktopApplicationContext.main(MyApp.class, args);
+     *         }
+     *     }
+     * </pre>
+     */
+    public static void main(Class<? extends Application> applicationClass, String[] args) {
+        String [] newArgs = new String[args.length + 1];
+        System.arraycopy(args, 0, newArgs, 1, args.length);
+        newArgs[0] = applicationClass.getName();
+        main(newArgs);
+    }
+
     public static void main(String[] args) {
         if (application != null) {
             throw new IllegalStateException();