GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Added JavaFX source code. · SF5/Source-Code-from-Tutorials@9f8cc7e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • JavaFX
    • 001_javaFX
      • Main.java
    • 002_javaFX
      • Main.java
    • 003_javaFX
      • Main.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎JavaFX/001_javaFX/Main.java‎

Copy file name to clipboard
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import javafx.application.Application;
2+
import javafx.scene.Scene;
3+
import javafx.scene.control.Button;
4+
import javafx.scene.layout.StackPane;
5+
import javafx.stage.Stage;
6+
7+
public class Main extends Application {
8+
9+
Button button;
10+
11+
public static void main(String[] args) {
12+
launch(args);
13+
}
14+
15+
@Override
16+
public void start(Stage primaryStage) throws Exception {
17+
primaryStage.setTitle("Title of the Window");
18+
button = new Button();
19+
button.setText("Click me");
20+
StackPane layout = new StackPane();
21+
layout.getChildren().add(button);
22+
Scene scene = new Scene(layout, 300, 250);
23+
primaryStage.setScene(scene);
24+
primaryStage.show();
25+
}
26+
27+
}
Collapse file

‎JavaFX/002_javaFX/Main.java‎

Copy file name to clipboard
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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.layout.StackPane;
7+
import javafx.stage.Stage;
8+
9+
public class Main extends Application implements EventHandler<ActionEvent> {
10+
11+
Button button;
12+
13+
public static void main(String[] args) {
14+
launch(args);
15+
}
16+
17+
@Override
18+
public void start(Stage primaryStage) {
19+
primaryStage.setTitle("Title of Window");
20+
button = new Button();
21+
button.setText("Hey baby");
22+
23+
//This class will handle the button events
24+
button.setOnAction(this);
25+
26+
StackPane layout = new StackPane();
27+
layout.getChildren().add(button);
28+
Scene scene = new Scene(layout, 300, 250);
29+
primaryStage.setScene(scene);
30+
primaryStage.show();
31+
}
32+
33+
//When button is clicked, handle() gets called
34+
//Button click is an ActionEvent (also MouseEvents, TouchEvents, etc...)
35+
@Override
36+
public void handle(ActionEvent event) {
37+
if (event.getSource() == button)
38+
System.out.println("Hey Charlie!");
39+
}
40+
41+
}
Collapse file

‎JavaFX/003_javaFX/Main.java‎

Copy file name to clipboard
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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.layout.StackPane;
7+
import javafx.stage.Stage;
8+
9+
public class Main extends Application {
10+
11+
Button button;
12+
13+
public static void main(String[] args) {
14+
launch(args);
15+
}
16+
17+
@Override
18+
public void start(Stage primaryStage) {
19+
primaryStage.setTitle("Title of Window");
20+
button = new Button();
21+
button.setText("Click Me");
22+
23+
button.setOnAction(e -> System.out.println("Lambda expressions are awesome!"));
24+
25+
/*
26+
button.setOnAction(new EventHandler<ActionEvent>() {
27+
@Override
28+
public void handle(ActionEvent event) {
29+
System.out.println("Handle event using anonymous inner classes");
30+
}
31+
});
32+
*/
33+
34+
StackPane layout = new StackPane();
35+
layout.getChildren().add(button);
36+
Scene scene = new Scene(layout, 300, 250);
37+
primaryStage.setScene(scene);
38+
primaryStage.show();
39+
}
40+
41+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.