Semester 3 😎

This commit is contained in:
2023-08-14 11:41:26 -05:00
parent 02a88ea7fe
commit 8b9b520393
52 changed files with 1529 additions and 40 deletions

View File

@@ -0,0 +1,35 @@
/*
* 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.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
/**
*
* @author caleb
*/
public class BidirectionalBindingDemo {
public static void main(String[] args)
{
DoubleProperty d1 = new SimpleDoubleProperty(1);
DoubleProperty d2 = new SimpleDoubleProperty(2);
System.out.println("d1 is " + d1.getValue()
+ " and d2 is " + d2.getValue());
d1.bindBidirectional(d2);
System.out.println("d1 is " + d1.getValue()
+ " and d2 is " + d2.getValue());
d1.setValue(50.1);
System.out.println("d1 is " + d1.getValue()
+ " and d2 is " + d2.getValue());
d2.setValue(70.2);
System.out.println("d1 is " + d1.getValue()
+ " and d2 is " + d2.getValue());
}
}

View File

@@ -0,0 +1,29 @@
/*
* 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.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
/**
*
* @author caleb
*/
public class BindingDemo {
public static void main(String[] args)
{
DoubleProperty d1 = new SimpleDoubleProperty(1);
DoubleProperty d2 = new SimpleDoubleProperty(1);
d1.bind(d2);
System.out.println("d1 is " + d1.getValue()
+ " and d2 is " + d2.getValue());
d2.setValue(70.2);
System.out.println("d1 is " + d1.getValue()
+ " and d2 is" + d2.getValue());
//d1.set(33); // remove comment to crash the program.
// When you bind, you cannot change. It is like getting married.
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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 Checkerboard extends Application {
@Override
public void start(Stage primaryStage) throws Exception
{
Pane pane = new Pane(); // Create a pane object
Scene scene = new Scene(pane, 800, 800); // 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[8][8];
//Fill array with rectangle objects.
for (int i = 0; i < 8; ++i) {
for (int j = 0; j < 8; ++j) {
r[i][j] = new Rectangle();
}
}
int j = 0;
for (int i = 0; i < 8; ++i) {
for (j = 0; j < 8; ++j) {
r[i][j].setWidth(80);
r[i][j].setHeight(80);
if (j > 0) {
r[i][j].setX(r[i][j - 1].getX() + 75);
}
if ((i + j) % 2 == 0) {
r[i][j].setFill(Color.RED);
} else {
r[i][j].setFill(Color.BLACK);
}
r[i][j].setY((i + 1) * 75);
pane.getChildren().add(r[i][j]);
}
}
}
public static void main(String[] args)
{
launch(args);
}
}

View File

@@ -25,7 +25,7 @@ public class ShowRectangle extends Application {
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);
Rectangle r = new Rectangle(30, 30, 88, 44); // Crate a rectangle object with these dimentions.
r.setX(30);
r.setY(30);
r.setStroke(Color.BLUE); // Set the rectangle outline to Blue