Last updated December 12, 2008 00:56, by stemkev
Feedicon  
= Java FX for Eclipse = __TOC__ == Installation == === Install JavaFX SDK === Download JavaFX SDK for [http://java.sun.com/javafx/downloads Windows] or [http://java.sun.com/javafx/downloads Mac Os X]. Follow the installation instructions. === Install Eclipse === The plugin requires Eclipse 3.4 or newer. We recommend downloading Eclipse IDE for Java EE Developers for [http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/ganymede/SR1/eclipse-jee-ganymede-SR1-win32.zip Windows] or [http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/ganymede/SR1/eclipse-jee-ganymede-SR1-macosx-carbon.tar.gz Mac OS X]. Then follow the installation instructions. === Install Plugin === # Download plugin: # [http://kenai.com/downloads/eplugin/com.sun.javafx.eclipse.feature-win32-win32-x86-1.0.zip com.sun.javafx.eclipse.feature-win32-win32-x86-1.0.zip] for Windows # [http://kenai.com/downloads/eplugin/com.sun.javafx.eclipse.feature-macosx-carbon-x86-1.0.zip com.sun.javafx.eclipse.feature-macosx-carbon-x86-1.0.zip] for Mac OS X # Unzip into the eclipse installation directory # There should be new files in <code>''ECLIPSE_ROOT/''plugins</code> and <code>''ECLIPSE_ROOT/''features</code> # Run Eclipse == Hello World == === Creating JavaFX Project and Configuring JavaFX SDK === # Start eclipse. You will see the basic layout of the workbench.<br />[[image: new_workbench_java.png|New empty workbench]] # In the <span class="eclipseView">Package Explorer</span> view right-click and select <span class="menuNavigation">New &gt; Java Project</span><br />[[image: create_new_java_project.png|New Java Project menu]] # Create a new Java<sup>TM</sup> project. <br />[[image: new_project_wizard_step1.png|New empty workbench]] # Name it <span class="userEnter">MyJavaFXProject</span> and press the <span class="buttonPointer">Finish</span> button. The new project appears in the <span class="eclipseView">Package Explorer</span>. <br />[[image: new_project_wizard_result.png|New project created]] # Right-click on the newly created project and select <span class="menuNavigation">JavaFX &gt; Add JavaFX Nature</span>. <br />[[image: add_javafx_nature.png|Add JavaFX nature to Java Project]] # The <span class="eclipseView">JavaFX</span> perspective is activated. If this is first time you are adding the JavaFX nature to a Java Project you will be asked to set the <code>JAVAFX_HOME</code> property. <br />[[image: missing_javafx_sdk_message.png|Error, JavaFX SDK home not set up.]]<br /> To set up the <code>JAVAFX_HOME</code> property, follow these steps: ## Press <span class="buttonPointer">OK</span> on message dialog. No thanks, I prefer <span class="buttonPointer">[[#IWantSelectCancel|Cancel]]</span> button. ## You should see the below dialog with <code>JAVAFX_HOME</code> set to (empty) value. <br />[[image: preferences_setup_javafx_sdk_path.png|Preferences: Classpath Variables]] ## Press <span class="buttonPointer">Edit...</span> button on the right side to bring up the edit window. <br />[[image: edit_variable_entry.png|Edit classpath variable]] ## Press the <span class="buttonPointer">Folder...</span> button and select the installation folder of the JavaFX SDK. <br />[[image: folder_selection_javafs_sdk_root_folder.png|Select instalation folder of JavaFX SDK]] ## Press <span class="buttonPointer">OK</span> on <span class="eclipseView">Folder Selection</span> dialog, press <span class="buttonPointer">OK</span> on <span class="eclipseView">Edit Variable Entry</span> dialog. <br />[[image: preference_setup_result.png|Result of setting JAVAFX_HOME property]] ## Press <span class="buttonPointer">OK</span> on <span class="eclipseView">Preferences</span> dialog. The <code>JAVAFX_HOME</code> variable has been set. If you decided to select the <span class="buttonPointer">Cancel</span> button on the error dialog you will skip this setup and the system will never ask you for this again. To set this up later just [[#sorryISelectCancel|follow these instructions]]. # Voila! you have created your first JavaFX Project. <br />[[image: javafx_perspective_overview.png|Opened JavaFX Perspective with Java Project with JavaFX nature]] === Adding Files === # Expand <span class="userEnter">MyJavaFXProject</span>. Left click on <span class="folderId">src</span> folder. Then select <span class="menuNavigation">New &gt; Package</span> and type into the <span class="buttonPointer">Name</span> field the package name <span class="userEnter">com.sun.eclipse.example</span>. <br />[[image: create_new_package.png|Adds new Empty Script file into folder.]] # Left click on <span class="folderId">src/com.sun.eclipse.example</span> folder. Then select <span class="menuNavigation">New &gt; Empty Script</span>. <br />[[image: new_file_empty_script_menu.png|Adds new Empty Script file into folder.]] # The <span class="eclipseView">New File</span> wizard will appear. Type <span class="userEnter">Main</span> into the <span class="buttonPointer">Name</span> field. <br />[[image: new_file_wizard.png|New file wizzard]] # Press the <span class="buttonPointer">Finish</span> button and an empty new JavaFX script will be created. <br />[[image: new_file_result.png|New empty FX script]] # Let's focus on <span class="eclipseView">Snippets</span> view. There are a lot of code snippets to help you develop your application. Expand <span class="buttonPointer">Applications</span> and select <span class="eclipseView">Stage</span>. <br />[[image: snippets_applications.png|Snippets View]] # Drag and drop a <span class="buttonPointer">Stage</span> node into the editor window. The <span class="eclipseView">Insert Template: Stage</span> dialog appears. Change the value of the title variable to <span class="userEnter">Hello World!</span>. <br />[[image: drag_stage_into_editor.png|Result after drop]] # Press the <span class="buttonPointer">Insert</span> button to insert the resulting template into the source code. <br />[[image: result_after_drop_stage.png|Result in editor]] # <span class="scream">Mission accomplished, Sir!</span> === Running === Running the application in Eclipse is extremely easy. # Press the <span class="buttonPointer">Run</span> button on the toolbar to launch the application. <br />[[image: run_file_icon_detail.png|Run icon]] # If you are running for the first time the <span class="eclipseView">Edit Configuration</span> dialog appears. <br />[[image: runnig_configuration.png|Configuration]]<br /> All options are set to default values. The most interesting part is the <span class="buttonPointer">Profile - Target</span> option. Here you can set up the execution environment. Possible options are: #* Desktop profile - Run as Application #* Desktop profile - Run as Applet #* Desktop profile - Run with WebStart #* Mobile Profile<sup>[[#switchingProfiles|[?]]]</sup> - Run in Emulator # Press <span>Run</span> to start the application. The console window will appear notifying you about progress of execution. <br />[[image: running_as_application.png|Running application]] === Building === Building in Eclipse is provided automatically by default. For more building options open the <span class="menuNavigation">Project</span> menu === Configuration Options === # Right-click the project in the <span class="eclipseView">Package Explorer</span>, and select <span class="menuNavigation">Properties</span>. <br />[[image: project_properties_menu.png|Menu: Project Properties]] # The <span class="eclipseView">Properties</span> dialog appears. Select <span class="buttonPointer">JavaFX Defaults</span>. <br />[[image: javafx_project_properties.png|Properties: JavaFX Defaults]]<br /> Here you can edit several default parameters used during the execution and deployment process of JavaFX Projects. For more information about the meaning of available options see the JavaFX Packager Documentation. === JavaFX Help === The plugin provides easy access to the JavaFX SDK documentation. You can invoke help by <span class="menuNavigation"> Help &gt; Java FX &gt; JavaFX Script Documentation </span> or press <code>Ctrl + F1</code><br />[[image: help_button.png|JavaFX SDK Help]] <div class="footNotes"> === Footnotes: === * At any time you can setup or change the <code>JAVAFX_HOME</code> variable by following these steps: *# Open <span class="menuNavigation">Window &gt; Preferences</span> *# Expand <span class="menuNavigation">Java &gt; Build Path</span> and select <span class="buttonPointer">Classpath Variables</span> *# Edit <code>JAVAFX_HOME</code> * You can switch profiles in SDK by following these steps: *# Right click on project name. Select <span class="menuNavigation">Properties &gt; Java Build Path &gt; Libraries</span> *# Double click on <span class="buttonPointer">JavaFX System Library</span>. The <span class="eclipseView">Edit Library</span> dialog appears. Here you can set the profile to use. <br />[[image: edit_javafx_system_library.png|Dialog: Edit JavaFX System Library]] </div>
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close