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 — Initial commit. · SF5/Source-Code-from-Tutorials@f64d1d5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • JavaFX
    • 001_introductionToJavaFX.txt
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎JavaFX/001_introductionToJavaFX.txt‎

Copy file name to clipboard
+47Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
//Calls launch in superclass
12+
//This sets up program as JavaFX application then calls start()
13+
public static void main(String[] args) {
14+
launch(args);
15+
}
16+
17+
//Every JavaFX program needs this method
18+
//Only parameter is stage (the main window)
19+
@Override
20+
public void start(Stage primaryStage) {
21+
22+
primaryStage.setTitle("Hello World!");
23+
Button btn = new Button();
24+
btn.setText("Hey baby");
25+
26+
/*
27+
When button is clicked, an action occurs
28+
btn.setOnAction(new EventHandler<ActionEvent>() {
29+
@Override
30+
public void handle(ActionEvent event) {
31+
System.out.println("Hello World!");
32+
}
33+
});
34+
*/
35+
36+
//A layout pane is how you want everything to be positioned and displayed
37+
//Will make a lot more sense when we have more than one item
38+
StackPane layout = new StackPane();
39+
layout.getChildren().add(btn);
40+
41+
//Add a scene to the stage (content to the window)
42+
Scene scene = new Scene(layout, 300, 250);
43+
primaryStage.setScene(scene);
44+
primaryStage.show();
45+
}
46+
47+
}

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.