JavaFXPluginTutorial

(Difference between revisions)
(JavaFX Script language Tutorial)
(Create a simple JavaFX Application)
 
Line 26: Line 26:
<pre>
<pre>
import javafx.stage.*;
import javafx.stage.*;
-
 
import javafx.scene.*;
import javafx.scene.*;
import javafx.scene.text.*;
import javafx.scene.text.*;
import javafx.scene.paint.*;
import javafx.scene.paint.*;
import javafx.scene.effect.*;
import javafx.scene.effect.*;
-
 
Stage {
Stage {
-
title: "JavaFX Hello World"
+
    title: "JavaFX Hello World"
-
width: 250
+
    width: 250
-
height: 80
+
    height: 80
-
scene: Scene {
+
    scene: Scene {
-
content: Text {
+
        content: Text {
-
x: 10 y: 30
+
            x: 10 y: 30
-
font: Font { size: 24 }
+
            font: Font { size: 24 }
-
fill: Color.BLUE
+
            fill: Color.BLUE
-
effect: DropShadow{ offsetX: 3 offsetY: 3}
+
            effect: DropShadow { offsetX: 3 offsetY: 3 }
-
content: "Hello World!"
+
            content: "Hello World!"
-
}
+
        }
-
}
+
    }
}
}
 +
</pre>
</pre>
# Change title "Application title" to  "JavaFX Hello World"
# Change title "Application title" to  "JavaFX Hello World"

Current revision as of 14:30, 25 November 2009

Contents


Install NetBeans 6.8 Beta and JavaFX plugin

  1. Go to the NetBeans Download page
  2. Download and Install one of the following options
    1. NetBeans 6.8 with the JavaFX Bundle
    2. NetBeans 6.8 Full installation
    3. NetBeans 6.8 (any version) and add the JavaFX Plugins from the Tools->Plugins->Available Plugins dialog.

Create a simple JavaFX Application

  1. Launch the IDE
  2. Invoke File| New Project... from the main menu bar.
  3. Under Categories, select JavaFX.
  4. Under Projects, select JavaFX Script Application.
  5. Click Next.
  6. In the Project Name field, type HelloWorld.
  7. Click Finish.
  • The HelloWorld JavaFX project is created
  • The Main.fx file opens

File:javafx_project_JavaFXPluginTutorial.png

8. Copy the code to the editor

import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.text.*;
import javafx.scene.paint.*;
import javafx.scene.effect.*;

Stage {
    title: "JavaFX Hello World"
    width: 250
    height: 80
    scene: Scene {
        content: Text {
            x: 10 y: 30
            font: Font { size: 24 }
            fill: Color.BLUE
            effect: DropShadow { offsetX: 3 offsetY: 3 }
            content: "Hello World!"
        }
    }
}

  1. Change title "Application title" to "JavaFX Hello World"
  2. Add Content to your page
    1. Change the font size to 24
    2. Add the "fill:" attribute to the Text node
    3. Drag the color you want from the palette and drop it in the code immediately following the "fill:"
    4. Add the "effect:" attribute to the text block
    5. Drag the Drop Shadow effect from the palette and drop it in the code immediately following the "effect:"
    6. Change the content from "Application Text" to "Hello World!"


9. Press F6 to run the JavaFX project

  • The JavaFX Hello World application appears

File:javafx_helloworld_JavaFXPluginTutorial.png

To learn more about JavaFX

Use the JavaFX Tutorial Overview to create JavaFX Script applications which include

  • 2D Graphics
  • UI Controls
  • Effects
  • Animation
  • Video and Audio

Learn more about the JavaFX Script language

JavaFX Plugin Features

  • Editor
  • Code Highlighting
  • Code Completion
  • Source Navigation
  • Code Folding
  • Javadoc
  • Error Detection
  • Refactoring
  • To enable the refactoring add the -J-Djavafx.refactoring=true flag to the netbeans.conf file
  • Palette
  • Deployment
  • Desktop
  • Applet
  • WebStart
  • Mobile Emulator
  • Debuger
  • Profiler
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo