Skip to content

Commit 3029e4c

Browse files
committed
JavaFX Controller Communication Example added
1 parent 37e8645 commit 3029e4c

19 files changed

Lines changed: 5886 additions & 1 deletion

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.geometry.Point3D?>
4+
<?import javafx.scene.layout.AnchorPane?>
5+
<?import javafx.scene.shape.Arc?>
6+
7+
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.171" fx:controller="custombuttons.FXMLController">
8+
<Arc fx:id="arc1" fill="#f5000008" layoutX="200.0" layoutY="200.0" length="80.0" radiusX="78.0" radiusY="101.0" rotate="-16.9" scaleZ="2.0" stroke="#f80808" strokeLineJoin="BEVEL" strokeMiterLimit="1.0" strokeWidth="9.0" translateX="1.0">
9+
<rotationAxis>
10+
<Point3D x="2.0" y="1.0" z="2.0" />
11+
</rotationAxis>
12+
</Arc>
13+
</AnchorPane>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package custombuttons;
2+
3+
import java.net.URL;
4+
import java.util.ResourceBundle;
5+
import javafx.animation.RotateTransition;
6+
import javafx.fxml.FXML;
7+
import javafx.fxml.Initializable;
8+
import javafx.geometry.Point3D;
9+
import javafx.scene.shape.Arc;
10+
import javafx.util.Duration;
11+
12+
/**
13+
* FXML Controller class
14+
* @author Villan
15+
*/
16+
public class FXMLController implements Initializable {
17+
18+
@FXML
19+
private Arc arc1;
20+
21+
/**
22+
* Initializes the controller class.
23+
*/
24+
@Override
25+
public void initialize(URL url, ResourceBundle rb) {
26+
RotateTransition transition = new RotateTransition(Duration.seconds(5), arc1);
27+
transition.setAxis(new Point3D(50, 50, 0));
28+
transition.setByAngle(200);
29+
transition.play();
30+
}
31+
32+
}

JavaFX Custom Shape Buttons/src/custombuttons/Launch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Launch extends Application {
1414

1515
@Override
1616
public void start(Stage stage) throws Exception {
17-
Parent root = FXMLLoader.load(getClass().getResource("roundbtn.fxml"));
17+
Parent root = FXMLLoader.load(getClass().getResource("FXML.fxml"));
1818
Scene scene = new Scene(root);
1919
stage.setScene(scene);
2020
stage.setTitle("Round Buttons");
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
nbproject/private/
2+
3+
build/
4+
5+
nbbuild/
6+
7+
dist/
8+
9+
nbdist/
10+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?><!-- You may freely edit this file. See commented blocks below for --><!-- some examples of how to customize the build. --><!-- (If you delete it and reopen the project it will be recreated.) --><!-- By default, only the Clean and Build commands use this build script. --><project name="JavaFXControllerCommunication" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
2+
<description>Builds, tests, and runs the project JavaFXControllerCommunication.</description>
3+
<import file="nbproject/build-impl.xml"/>
4+
<!--
5+
6+
There exist several targets which are by default empty and which can be
7+
used for execution of your tasks. These targets are usually executed
8+
before and after some main targets. Those of them relevant for JavaFX project are:
9+
10+
-pre-init: called before initialization of project properties
11+
-post-init: called after initialization of project properties
12+
-pre-compile: called before javac compilation
13+
-post-compile: called after javac compilation
14+
-pre-compile-test: called before javac compilation of JUnit tests
15+
-post-compile-test: called after javac compilation of JUnit tests
16+
-pre-jfx-jar: called before FX SDK specific <fx:jar> task
17+
-post-jfx-jar: called after FX SDK specific <fx:jar> task
18+
-pre-jfx-deploy: called before FX SDK specific <fx:deploy> task
19+
-post-jfx-deploy: called after FX SDK specific <fx:deploy> task
20+
-pre-jfx-native: called just after -pre-jfx-deploy if <fx:deploy> runs in native packaging mode
21+
-post-jfx-native: called just after -post-jfx-deploy if <fx:deploy> runs in native packaging mode
22+
-post-clean: called after cleaning build products
23+
24+
(Targets beginning with '-' are not intended to be called on their own.)
25+
26+
Example of inserting a HTML postprocessor after javaFX SDK deployment:
27+
28+
<target name="-post-jfx-deploy">
29+
<basename property="jfx.deployment.base" file="${jfx.deployment.jar}" suffix=".jar"/>
30+
<property name="jfx.deployment.html" location="${jfx.deployment.dir}${file.separator}${jfx.deployment.base}.html"/>
31+
<custompostprocess>
32+
<fileset dir="${jfx.deployment.html}"/>
33+
</custompostprocess>
34+
</target>
35+
36+
Example of calling an Ant task from JavaFX SDK. Note that access to JavaFX SDK Ant tasks must be
37+
initialized; to ensure this is done add the dependence on -check-jfx-sdk-version target:
38+
39+
<target name="-post-jfx-jar" depends="-check-jfx-sdk-version">
40+
<echo message="Calling jar task from JavaFX SDK"/>
41+
<fx:jar ...>
42+
...
43+
</fx:jar>
44+
</target>
45+
46+
For more details about JavaFX SDK Ant tasks go to
47+
http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm
48+
49+
For list of available properties check the files
50+
nbproject/build-impl.xml and nbproject/jfx-impl.xml.
51+
52+
-->
53+
</project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
X-COMMENT: Main-Class will be added automatically by build
3+

0 commit comments

Comments
 (0)