< prev index next >

modules/javafx.graphics/src/main/java/javafx/application/Application.java

Print this page
rev 10443 : 8177341: Fix typos in FX API docs
Reviewed-by:


  70  * public no-argument constructor.</p>
  71  *
  72  * <p>Calling {@link Platform#exit} is the preferred way to explicitly terminate
  73  * a JavaFX Application. Directly calling {@link System#exit} is
  74  * an acceptable alternative, but doesn't allow the Application {@link #stop}
  75  * method to run.
  76  * </p>
  77  *
  78  * <p>A JavaFX Application should not attempt to use JavaFX after the
  79  * FX toolkit has terminated or from a ShutdownHook, that is, after the
  80  * {@link #stop} method returns or {@link System#exit} is called.
  81  * </p>
  82  *
  83  * <p><b>Deploying an Application as a Module</b></p>
  84  * <p>
  85  * If the {@code Application} subclass is in a named module then that class
  86  * must be accessible to the {@code javafx.graphics} module.
  87  * Otherwise, an exception will be thrown when the application is launched.
  88  * This means that
  89  * in addition to the class itself being declared public, the module must
  90  * {@link Module#isExported(String,Module) export} the containing package to
  91  * at least the {@code javafx.graphics} module, either in its
  92  * {@code module-info.class} or by calling
  93  * {@link Module#addExports}.
  94  * </p>
  95  * <p>
  96  * For example, if the {@code Application} subclass is in the {@code com.foo}
  97  * package in the {@code foo.app} module, the {@code module-info.java} might
  98  * look like this:
  99  * </p>
 100  * <pre>{@code module foo.app {
 101  *     exports com.foo to javafx.graphics;
 102  * }}</pre>
 103  *
 104  * <p><b>Parameters</b></p>
 105  * <p>
 106  * Application parameters are available by calling the {@link #getParameters}
 107  * method from the {@link #init} method, or any time after the {@code init}
 108  * method has been called.
 109  * </p>
 110  *
 111  * <p><b>Threading</b></p>
 112  * <p>
 113  * JavaFX creates an application thread for running the application start
 114  * method, processing input events, and running animation timelines. Creation
 115  * of JavaFX {@link Scene} and {@link Stage} objects as well as modification of
 116  * scene graph operations to <em>live</em> objects (those objects already
 117  * attached to a scene) must be done on the JavaFX application thread.
 118  * </p>
 119  *
 120  * <p>
 121  * The Java launcher loads and initializes the specified Application class
 122  * on the JavaFX Application Thread. If there is no main method in the
 123  * Application class, or if the main method calls Application.launch(), then


 177      * is the theme that shipped as default in JavaFX 2.x.
 178      * @since JavaFX 8.0
 179      */
 180     public static final String STYLESHEET_CASPIAN = "CASPIAN";
 181     /**
 182      * Constant for user agent stylesheet for the "Modena" theme. Modena
 183      * is the default theme for JavaFX 8.x.
 184      * @since JavaFX 8.0
 185      */
 186     public static final String STYLESHEET_MODENA = "MODENA";
 187 
 188     /**
 189      * Launch a standalone application. This method is typically called
 190      * from the main method(). It must not be called more than once or an
 191      * exception will be thrown.
 192      *
 193      * <p>
 194      * The launch method does not return until the application has exited,
 195      * either via a call to Platform.exit or all of the application windows
 196      * have been closed.






 197      *
 198      * <p>
 199      * Typical usage is:
 200      * <pre>
 201      *     public static void main(String[] args) {
 202      *         Application.launch(MyApp.class, args);
 203      *     }
 204      * </pre>
 205      * where <code>MyApp</code> is a subclass of Application.
 206      *
 207      * @param appClass the application class that is constructed and executed
 208      *        by the launcher.
 209      * @param args the command line arguments passed to the application.
 210      *             An application may get these parameters using the
 211      *             {@link #getParameters()} method.
 212      *
 213      * @throws IllegalStateException if this method is called more than once.
 214      * @throws IllegalArgumentException if <code>appClass</code> is not a
 215      *         subclass of <code>Application</code>.
 216      * @throws RuntimeException if there is an error launching the
 217      * JavaFX runtime, or if the application class cannot be constructed
 218      * (e.g., if the class is not public or is not in an exported package), or
 219      * if an Exception or Error is thrown by the Application constructor, init
 220      * method, start method, or stop method.
 221      */
 222     public static void launch(Class<? extends Application> appClass, String... args) {
 223         LauncherImpl.launchApplication(appClass, args);
 224     }
 225 
 226     /**
 227      * Launch a standalone application. This method is typically called
 228      * from the main method(). It must not be called more than once or an
 229      * exception will be thrown.
 230      * This is equivalent to launch(TheClass.class, args) where TheClass is the
 231      * immediately enclosing class of the method that called launch. It must
 232      * be a public subclass of Application with a public no-argument
 233      * constructor, in a package that is

 234      * {@link Module#isExported(String,Module) exported}
 235      * (or {@link Module#isOpen(String,Module) opened}) to at least the
 236      * {@code javafx.graphics} module, or a RuntimeException will be thrown.
 237      *
 238      * <p>
 239      * The launch method does not return until the application has exited,
 240      * either via a call to Platform.exit or all of the application windows
 241      * have been closed.
 242      *
 243      * <p>
 244      * Typical usage is:
 245      * <pre>
 246      *     public static void main(String[] args) {
 247      *         Application.launch(args);
 248      *     }
 249      * </pre>
 250      *
 251      * @param args the command line arguments passed to the application.
 252      *             An application may get these parameters using the
 253      *             {@link #getParameters()} method.
 254      *
 255      * @throws IllegalStateException if this method is called more than once.




  70  * public no-argument constructor.</p>
  71  *
  72  * <p>Calling {@link Platform#exit} is the preferred way to explicitly terminate
  73  * a JavaFX Application. Directly calling {@link System#exit} is
  74  * an acceptable alternative, but doesn't allow the Application {@link #stop}
  75  * method to run.
  76  * </p>
  77  *
  78  * <p>A JavaFX Application should not attempt to use JavaFX after the
  79  * FX toolkit has terminated or from a ShutdownHook, that is, after the
  80  * {@link #stop} method returns or {@link System#exit} is called.
  81  * </p>
  82  *
  83  * <p><b>Deploying an Application as a Module</b></p>
  84  * <p>
  85  * If the {@code Application} subclass is in a named module then that class
  86  * must be accessible to the {@code javafx.graphics} module.
  87  * Otherwise, an exception will be thrown when the application is launched.
  88  * This means that
  89  * in addition to the class itself being declared public, the module must
  90  * {@link Module#isExported(String,Module) export}
  91  * (or {@link Module#isOpen(String,Module) open}) the containing package to
  92  * at least the {@code javafx.graphics} module.

  93  * </p>
  94  * <p>
  95  * For example, if {@code com.foo.MyApplication} is in the {@code foo.app}
  96  * module, the {@code module-info.java} might look like this:
  97  * </p>
  98 <pre>{@code module foo.app {
  99     exports com.foo to javafx.graphics;
 100 }}</pre>
 101 *

 102  * <p><b>Parameters</b></p>
 103  * <p>
 104  * Application parameters are available by calling the {@link #getParameters}
 105  * method from the {@link #init} method, or any time after the {@code init}
 106  * method has been called.
 107  * </p>
 108  *
 109  * <p><b>Threading</b></p>
 110  * <p>
 111  * JavaFX creates an application thread for running the application start
 112  * method, processing input events, and running animation timelines. Creation
 113  * of JavaFX {@link Scene} and {@link Stage} objects as well as modification of
 114  * scene graph operations to <em>live</em> objects (those objects already
 115  * attached to a scene) must be done on the JavaFX application thread.
 116  * </p>
 117  *
 118  * <p>
 119  * The Java launcher loads and initializes the specified Application class
 120  * on the JavaFX Application Thread. If there is no main method in the
 121  * Application class, or if the main method calls Application.launch(), then


 175      * is the theme that shipped as default in JavaFX 2.x.
 176      * @since JavaFX 8.0
 177      */
 178     public static final String STYLESHEET_CASPIAN = "CASPIAN";
 179     /**
 180      * Constant for user agent stylesheet for the "Modena" theme. Modena
 181      * is the default theme for JavaFX 8.x.
 182      * @since JavaFX 8.0
 183      */
 184     public static final String STYLESHEET_MODENA = "MODENA";
 185 
 186     /**
 187      * Launch a standalone application. This method is typically called
 188      * from the main method(). It must not be called more than once or an
 189      * exception will be thrown.
 190      *
 191      * <p>
 192      * The launch method does not return until the application has exited,
 193      * either via a call to Platform.exit or all of the application windows
 194      * have been closed.
 195      * The class specified by the {@code appClass} argument must be
 196      * a public subclass of {@code Application}
 197      * with a public no-argument constructor, in a package that is
 198      * {@link Module#isExported(String,Module) exported}
 199      * (or {@link Module#isOpen(String,Module) open}) to at least the
 200      * {@code javafx.graphics} module, or a RuntimeException will be thrown.
 201      *
 202      * <p>
 203      * Typical usage is:
 204      * <pre>
 205      *     public static void main(String[] args) {
 206      *         Application.launch(MyApp.class, args);
 207      *     }
 208      * </pre>
 209      * where <code>MyApp</code> is a subclass of Application.
 210      *
 211      * @param appClass the application class that is constructed and executed
 212      *        by the launcher.
 213      * @param args the command line arguments passed to the application.
 214      *             An application may get these parameters using the
 215      *             {@link #getParameters()} method.
 216      *
 217      * @throws IllegalStateException if this method is called more than once.
 218      * @throws IllegalArgumentException if <code>appClass</code> is not a
 219      *         subclass of <code>Application</code>.
 220      * @throws RuntimeException if there is an error launching the
 221      * JavaFX runtime, or if the application class cannot be constructed
 222      * (e.g., if the class is not public or is not in an exported package), or
 223      * if an Exception or Error is thrown by the Application constructor, init
 224      * method, start method, or stop method.
 225      */
 226     public static void launch(Class<? extends Application> appClass, String... args) {
 227         LauncherImpl.launchApplication(appClass, args);
 228     }
 229 
 230     /**
 231      * Launch a standalone application. This method is typically called
 232      * from the main method(). It must not be called more than once or an
 233      * exception will be thrown.
 234      * This is equivalent to {@code launch(TheClass.class, args)} where
 235      * {@code TheClass} is the
 236      * immediately enclosing class of the method that called launch.
 237      * It must be a public subclass of {@code Application}
 238      * with a public no-argument constructor, in a package that is
 239      * {@link Module#isExported(String,Module) exported}
 240      * (or {@link Module#isOpen(String,Module) open}) to at least the
 241      * {@code javafx.graphics} module, or a RuntimeException will be thrown.
 242      *
 243      * <p>
 244      * The launch method does not return until the application has exited,
 245      * either via a call to Platform.exit or all of the application windows
 246      * have been closed.
 247      *
 248      * <p>
 249      * Typical usage is:
 250      * <pre>
 251      *     public static void main(String[] args) {
 252      *         Application.launch(args);
 253      *     }
 254      * </pre>
 255      *
 256      * @param args the command line arguments passed to the application.
 257      *             An application may get these parameters using the
 258      *             {@link #getParameters()} method.
 259      *
 260      * @throws IllegalStateException if this method is called more than once.


< prev index next >