This commit is contained in:
2023-08-21 12:39:02 -05:00
parent 8b9b520393
commit 6e234d2266
62 changed files with 15370 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package lab2_fx2_f22_part1;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.text.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
/**
*
* @author caleb
*/
public class FontDemo1 extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
// Create a pane to hold the circle and label
Pane pane = new StackPane();
// Create a scene and place it in the stage
Scene scene = new Scene(pane);
// Add the scene to the stage
primaryStage.setScene(scene);
//Set the stage title
primaryStage.setTitle("FontDemo1");
// Create Node circle and add to the Pane
Circle circle = new Circle();
circle.setRadius(300);
circle.setStroke(Color.BLACK);
circle.setFill(new Color(0.9, 0.1, 0.1, 0.1));
// Add circle to the pane
pane.getChildren().add(circle);
// Create node label and add to Pane
Label label = new Label("JavaFX");
// Font created via static method font() and set the font into the label
label.setFont(Font.font("Comic Sans MS",
FontWeight.BOLD, FontPosture.ITALIC, 96));
}
}

View File

@@ -0,0 +1,67 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package lab2_fx2_f22_part1;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import style.ButtonStyle;
/**
*
* @author Athanasios V. Markou
*/
public class HandleClickEvent extends Application
{
@Override
public void start(Stage primaryStage) throws Exception
{
Button buttonOK = new Button("OK");
buttonOK.setStyle(ButtonStyle.getStyle());
OKHandlerClass eventHnadlerOK = new OKHandlerClass();
buttonOK.setOnAction(eventHnadlerOK);
Button buttonCancel = new Button("Cancel");
buttonCancel.setStyle(ButtonStyle.getStyle());
CancelHandlerClass eventHandlerCancel = new CancelHandlerClass();
buttonCancel.setOnAction(eventHandlerCancel);
BorderPane pane = new BorderPane();
pane.setTop(buttonOK);
pane.setBottom(buttonCancel);
Scene scene = new Scene( pane);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args)
{
launch( args);
}
private static class OKHandlerClass implements EventHandler<ActionEvent> {
@Override
public void handle(ActionEvent event) {
System.out.println("You clicked OK!");
}
}
private static class CancelHandlerClass implements EventHandler<ActionEvent> {
@Override
public void handle(ActionEvent event) {
System.out.println("You clicked Cancel!");
}
}
}

View File

@@ -0,0 +1,50 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package lab2_fx2_f22_part1;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import style.ButtonStyle;
/**
*
* @author Athanasios V. Markou
*/
public class HandleClickEventAnonymous extends Application
{
@Override
public void start(Stage primaryStage) throws Exception
{
Button button = new Button("OK");
button.setStyle(ButtonStyle.getStyle());
EventHandler eventHnadler = new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t)
{
System.out.println("You clicked OK!");
}
};
button.setOnAction(eventHnadler);
Pane pane = new Pane();
pane.getChildren().add(button);
Scene scene = new Scene( pane);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args)
{
launch( args);
}
}

View File

@@ -0,0 +1,54 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/javafx/FXMain.java to edit this template
*/
package lab2_fx2_f22_part1;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import style.ButtonStyle;
/**
*
* @author caleb
*/
public class Lab2_FX2_F22_part1 extends Application {
@Override
public void start(Stage primaryStage)
{
String style = ButtonStyle.getStyle();
Button btn = new Button();
btn.setStyle(style);
btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event)
{
System.out.println("Hello World!");
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
launch(args);
}
}