MP5
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package javafx_calebfontenot;
|
||||
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;
|
||||
|
||||
public class JavaFX_CalebFontenot extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage)
|
||||
{
|
||||
Button btn = new Button();
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 javafx_calebfontenot;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class ShowCircle extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage)
|
||||
{
|
||||
Pane pane = new Pane(); // Create a pane object
|
||||
Scene scene = new Scene(pane, 300, 200); // Create a scene object
|
||||
primaryStage.setScene(scene); // Set the stage scene to the scene object
|
||||
primaryStage.show(); // Make the window display on the screen
|
||||
Circle c = new Circle(20); // Create a circle object
|
||||
c.setCenterX(150); // Set the center X for the circle object to '150'
|
||||
c.setCenterY(80); // Set the center Y for the circle object to '80'
|
||||
c.setStroke(Color.BLUE); // Set the circle outline to Blue
|
||||
c.setFill(Color.RED); // Set the interior of the circle to Red
|
||||
pane.getChildren().add(c); // Add the circle object to the pane
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
launch(args);
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 javafx_calebfontenot;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class ShowCircleCentered extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage)
|
||||
{
|
||||
// Create a pane to hold the Circle
|
||||
Pane pane = new Pane();
|
||||
|
||||
// Create a circle and set its properties
|
||||
Circle circle = new Circle();
|
||||
circle.centerXProperty().bind(pane.widthProperty().divide(2));
|
||||
circle.centerYProperty().bind(pane.heightProperty().divide(2));
|
||||
circle.setRadius(50);
|
||||
circle.setStroke(Color.BLACK);
|
||||
circle.setFill(Color.WHITE);
|
||||
pane.getChildren().add(circle); // Add the circle to the pane
|
||||
|
||||
// Create a scene and place it in the stage
|
||||
Scene scene = new Scene(pane, 200, 200);
|
||||
primaryStage.setTitle("ShowCircleCentered"); // Set the stage title
|
||||
primaryStage.setScene(scene); // Place the scene in the stage
|
||||
primaryStage.show(); // Display the stage
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
launch(args);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 javafx_calebfontenot;
|
||||
|
||||
import javafx.application.Application;
|
||||
import static javafx.application.Application.launch;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class ShowRectangle extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage)
|
||||
{
|
||||
Pane pane = new Pane(); // Create a pane object
|
||||
Scene scene = new Scene(pane, 300, 200); // Create a scene object
|
||||
primaryStage.setScene(scene); // Set the stage scene to the scene object
|
||||
primaryStage.show(); // Make the window display on the screen
|
||||
Rectangle r = new Rectangle(30, 30, 88, 44);
|
||||
r.setX(30);
|
||||
r.setY(30);
|
||||
r.setStroke(Color.BLUE); // Set the rectangle outline to Blue
|
||||
r.setFill(Color.RED); // Set the interior of the rectangle to Red
|
||||
pane.getChildren().add(r); // Add the circle object to the pane
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
launch(args);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user