0% found this document useful (0 votes)
51 views3 pages

Introduction To JavaFX

1. JavaFX applications extend from the Application class which provides life cycle functions like initialize, launch, start and stop. 2. The main() method launches the application and the start() method contains the JavaFX code and runs on the JavaFX thread. 3. A Scene holds Nodes in a graph structure and is set on the Stage which represents the application window.

Uploaded by

DeepikaSingh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views3 pages

Introduction To JavaFX

1. JavaFX applications extend from the Application class which provides life cycle functions like initialize, launch, start and stop. 2. The main() method launches the application and the start() method contains the JavaFX code and runs on the JavaFX thread. 3. A Scene holds Nodes in a graph structure and is set on the Stage which represents the application window.

Uploaded by

DeepikaSingh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

JavaFX

applications
extend
from
the
javafx.application.Application class. The Application class
provides application life cycle functions such as initializing,
launching, starting, and stopping during runtime. This provides a
mechanism for Java applications to launch JavaFX GUI
components separate from the main thread.
Public class HelloWorldMain extends Application {
Public static void main(String[] args) {
//Main Thread
Application.launch(args);
}
Public void start (Stage PrimaryStage) {
//JavaFX application thread
//JavaFX code here
}
}

Steps:
1. In main() method we launch the FX application by passing in
command line arguments to the Application.launch()
method. To access the arguments passed into the launch()
method, we can invoke getParameters()method of the
Application
class.
2. After the Application.launch() method has executed, the
application will enter a ready state and the frameworks
internal will invoke a start() method. At this point, the
program execution occurs on the JavaFX application thread
and
not
on
the
main
thread.
3. When the start()
method is invoked, a JavaFX
javafx.stage.Stage object is available for the developer to
use
and
manipulate.

4. When the program begins in the start() method, a separate


thread of execution occurs, called the JavaFX application
thread.
JavaFX Scene Graph
1. In JavaFX the Stage is equivalent to an application window
similar to Java Swing API JFrame or JDialog on the desktop.
2. You can think of a Scene object as a content pane, similar to
Java Swings JPanel, capable of holding zero-to-many Node
objects.
To set the title of window, we use setTitle()
3. We create a root node (Group), which is added to the Scene
object as the top-level surface for the application window.
JavaFX Node
A JavaFX Node is a fundamental base class for all scene
graph nodes to be rendered. The following graphics
capabilities can be applied to Nodes: scaling, transforms,
translations, and effects.
A scene graph will contain children nodes by using a
container class such as the Group or Pane class.
Shapes in JavaFX
Line shape:
Instantiation can be: Line line = new
Line(100,10,100,10);
Or Line line = new Line();
Then calling startx, starty, endX,endY method.
Datatype of all parameter is dooble.

Line default stroke width is 1.0, default Color is Color.BLACK


NOTE: According to the Javadoc, all shapes have a stroke
color of null (no color) except Line, Polyline, and Path
nodes.
Properties that can be applied on a line (Shape)
Property

Data Type

Description

fill

javafx.scene.paint.Paint

A color to fill inside a shape.

smooth

Boolean

True turns on anti-aliasing, otherwise false.

strokeDashOffs
et
strokeLineCap

Double

strokeType

javafx.scene.shape.StrokeTyp Where to draw the stroke around the


e
boundary of a Shape node. There are
StrokeType.CENTERED,
StrokeType.INSIDE,
three
types:
and
StrokeType.OUTSIDE.
Double
A stroke lines width.

The offset (distance) into the dashed


pattern.
javafx.scene.shape.StrokeLine The cap style on the end of a line or path.
Cap
There are three styles:
StrokeLineCap.BUTT, StrokeLineCap.ROUND,
and StrokeLineCap.SQUARE.
strokeLineJoin
javafx.scene.shape.StrokeLin Decoration
when lines meet. There are three
eJoin
types: StrokeLineJoin.MITER,
StrokeLineJoin.BEVEL, and
StrokeLineJoin.ROUND.
strokeMiterLimi Double
The
limit of a miter joint. Used along
t
with the miter join decoration
(StrokeLineJoin.MITER).
stroke
javafx.scene.paint.Paint
A color for the shapes line stroke.

strokeWidth

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy