Skip to content

Commit dcb0bac

Browse files
committed
updated
1 parent 7447284 commit dcb0bac

10 files changed

+602
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Rustam_Z🚀, 9.10.2020
1515
- Java Exceptions:
1616
- https://www.javatpoint.com/exception-handling-in-java
1717

18-
- Design Patterns, SOLID Principles- https://youtu.be/A1PWJB98qcw
18+
- Design Patterns, SOLID Principles - https://youtu.be/A1PWJB98qcw
1919

2020
- [Java Swing](java-swing)
2121

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import javafx.application.Application;
2+
import javafx.event.ActionEvent;
3+
import javafx.event.EventHandler;
4+
import javafx.scene.Scene;
5+
import javafx.scene.control.Button;
6+
import javafx.scene.control.Label;
7+
import javafx.scene.layout.HBox;
8+
import javafx.stage.Stage;
9+
10+
public class ButtonExperiments extends Application {
11+
12+
@Override
13+
public void start(Stage primaryStage) throws Exception {
14+
primaryStage.setTitle("HBox Experiment 1");
15+
16+
Label label = new Label("Not clicked");
17+
Button button = new Button("Click");
18+
19+
button.setOnAction(value -> {
20+
label.setText("Clicked!");
21+
System.out.println("Button Clicked!");
22+
});
23+
24+
HBox hbox = new HBox(button, label);
25+
26+
Scene scene = new Scene(hbox, 200, 100);
27+
primaryStage.setScene(scene);
28+
primaryStage.show();
29+
30+
}
31+
32+
public static void main(String[] args) {
33+
Application.launch(args);
34+
}
35+
}
36+
37+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import javafx.application.Application;
2+
import static javafx.application.Application.launch;
3+
import javafx.event.EventHandler;
4+
5+
import javafx.scene.Group;
6+
import javafx.scene.Scene;
7+
import javafx.scene.input.MouseEvent;
8+
import javafx.scene.paint.Color;
9+
import javafx.scene.shape.Circle;
10+
11+
import javafx.scene.text.Font;
12+
import javafx.scene.text.FontWeight;
13+
import javafx.scene.text.Text;
14+
import javafx.stage.Stage;
15+
16+
public class EventFiltersExample extends Application {
17+
@Override
18+
public void start(Stage stage) {
19+
//Drawing a Circle
20+
Circle circle = new Circle();
21+
22+
//Setting the position of the circle
23+
circle.setCenterX(300.0f);
24+
circle.setCenterY(135.0f);
25+
26+
//Setting the radius of the circle
27+
circle.setRadius(25.0f);
28+
29+
//Setting the color of the circle
30+
circle.setFill(Color.BROWN);
31+
32+
//Setting the stroke width of the circle
33+
circle.setStrokeWidth(20);
34+
35+
//Setting the text
36+
Text text = new Text("Click on the circle to change its color");
37+
38+
//Setting the font of the text
39+
text.setFont(Font.font(null, FontWeight.BOLD, 15));
40+
41+
//Setting the color of the text
42+
text.setFill(Color.CRIMSON);
43+
44+
//setting the position of the text
45+
text.setX(150);
46+
text.setY(50);
47+
48+
//Creating the mouse event handler
49+
EventHandler<MouseEvent> eventHandler = new EventHandler<MouseEvent>() {
50+
@Override
51+
public void handle(MouseEvent e) {
52+
System.out.println("Hello World");
53+
circle.setFill(Color.DARKSLATEBLUE);
54+
}
55+
};
56+
//Registering the event filter
57+
circle.addEventFilter(MouseEvent.MOUSE_CLICKED, eventHandler);
58+
59+
//Creating a Group object
60+
Group root = new Group(circle, text);
61+
62+
//Creating a scene object
63+
Scene scene = new Scene(root, 600, 300);
64+
65+
//Setting the fill color to the scene
66+
scene.setFill(Color.LAVENDER);
67+
68+
//Setting title to the Stage
69+
stage.setTitle("Event Filters Example");
70+
71+
//Adding scene to the stage
72+
stage.setScene(scene);
73+
74+
//Displaying the contents of the stage
75+
stage.show();
76+
}
77+
public static void main(String args[]){
78+
launch(args);
79+
}
80+
}

javafx-tutorial/JavaFXLayoutDemo.java

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*import javafx.application.Application;
2+
import javafx.scene.Group;
3+
import javafx.scene.Scene;
4+
import javafx.scene.paint.Color;
5+
import javafx.scene.shape.Rectangle;
6+
import javafx.stage.Stage;
7+
8+
public class JavaFXLayoutDemo extends Application {
9+
10+
@Override
11+
public void start(Stage stage) {
12+
Group root = new Group();
13+
Scene scene = new Scene(root, 500, 500, Color.BLACK);
14+
15+
Rectangle r = new Rectangle(25,25,250,250);
16+
r.setFill(Color.BLUE);
17+
root.getChildren().add(r);
18+
19+
stage.setTitle("JavaFX Scene Graph Demo");
20+
stage.setScene(scene);
21+
stage.show();
22+
}
23+
24+
public static void main(String[] args) {
25+
launch(args);
26+
}
27+
}*/
28+
29+
30+
import javafx.application.Application;
31+
import javafx.scene.Group;
32+
import javafx.scene.Scene;
33+
import javafx.scene.paint.Color;
34+
import javafx.scene.shape.Rectangle;
35+
import javafx.stage.Stage;
36+
import javafx.scene.control.Label;
37+
import javafx.scene.control.Button;
38+
import javafx.scene.control.TextField;
39+
import javafx.scene.layout.HBox;
40+
import javafx.scene.layout.VBox;
41+
42+
public class JavaFXLayoutDemo extends Application {
43+
44+
@Override
45+
public void start(Stage stage) {
46+
47+
Label lblName = new Label("What is your Name ?");
48+
TextField tfName = new TextField("Type your name ");
49+
Button btOk = new Button("Ok");
50+
51+
HBox group = new HBox();
52+
53+
group.getChildren().add(lblName);
54+
group.getChildren().add(tfName);
55+
group.getChildren().add(btOk);
56+
57+
Scene scene = new Scene(group,500, 500);
58+
59+
stage.setTitle("JavaFX Scene Graph Demo");
60+
stage.setScene(scene);
61+
stage.show();
62+
}
63+
64+
public static void main(String[] args) {
65+
launch(args);
66+
}
67+
}
Binary file not shown.

javafx-tutorial/MyFxApp.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
3+
import javafx.application.Application;
4+
import javafx.stage.Stage;
5+
6+
public class MyFxApp extends Application {
7+
8+
@Override
9+
public void start(Stage primaryStage) throws Exception {
10+
primaryStage.setTitle("My First JavaFX App");
11+
12+
primaryStage.show();
13+
}
14+
15+
}
16+
17+
*/
18+
19+
20+
/*
21+
import javafx.application.Application;
22+
import javafx.stage.Stage;
23+
24+
public class MyFxApp extends Application {
25+
26+
@Override
27+
public void start(Stage primaryStage) throws Exception {
28+
primaryStage.setTitle("My First JavaFX App");
29+
30+
primaryStage.show();
31+
}
32+
33+
public static void main(String[] args) {
34+
Application.launch(args);
35+
}
36+
37+
38+
}
39+
*/
40+
41+
import javafx.application.Application;
42+
import javafx.scene.Scene;
43+
import javafx.scene.control.Label;
44+
import javafx.stage.Stage;
45+
46+
public class MyFxApp extends Application {
47+
48+
@Override
49+
public void start(Stage primaryStage) throws Exception {
50+
primaryStage.setTitle("My First JavaFX App");
51+
52+
Label label = new Label("Hello World, JavaFX !");
53+
Scene scene = new Scene(label, 400, 200);
54+
primaryStage.setScene(scene);
55+
56+
primaryStage.show();
57+
}
58+
59+
public static void main(String[] args) {
60+
Application.launch(args);
61+
}
62+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Download an appropriate JavaFX runtime for your operating system and unzip it to a desired location. For this tutorial, we will be using JavaFX .
2+
3+
Add an environment variable pointing to the lib directory of the runtime: (e.g. you have download and unziped "javafx-sdk-11.0.2")
4+
5+
6+
set PATH_TO_FX="C:\Program Files\javafx-sdk-11.0.2\lib"
7+
8+
You can now compile and run JavaFX applications from the command line using the JavaFX runtime.
9+
10+
Compile the application (e.g. use HelloFX.java from this sample) using:
11+
12+
javac --module-path %PATH_TO_FX% --add-modules javafx.controls HelloFX.java
13+
14+
Run the application (e.g. use HelloFX.java from this sample) using:
15+
16+
java --module-path %PATH_TO_FX% --add-modules javafx.controls HelloFX
17+
18+
reference : https://openjfx.io/openjfx-docs/#install-javafx
Binary file not shown.

0 commit comments

Comments
 (0)