AHHHHHHHHHH COMMITED TO GITHUB INSTEAD OF FORGEJO FOR WEEKS
This commit is contained in:
parent
d6ef44f3d1
commit
0919005cb2
163 changed files with 3875 additions and 47 deletions
51
Code/ost/_11_simpson-list/pom.xml
Normal file
51
Code/ost/_11_simpson-list/pom.xml
Normal file
|
@ -0,0 +1,51 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>_11_simpson-list</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>13</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<release>11</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Default configuration for running -->
|
||||
<!-- Usage: mvn clean javafx:run -->
|
||||
<id>default-cli</id>
|
||||
<configuration>
|
||||
<mainClass>com.example.App</mainClass>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
38
Code/ost/_11_simpson-list/src/main/java/com/example/App.java
Normal file
38
Code/ost/_11_simpson-list/src/main/java/com/example/App.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package com.example;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* JavaFX App
|
||||
*/
|
||||
public class App extends Application {
|
||||
|
||||
private static Scene scene;
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
scene = new Scene(loadFXML("primary"), 640, 480);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
static void setRoot(String fxml) throws IOException {
|
||||
scene.setRoot(loadFXML(fxml));
|
||||
}
|
||||
|
||||
private static Parent loadFXML(String fxml) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml"));
|
||||
return fxmlLoader.load();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.example;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
public class PrimaryController {
|
||||
|
||||
// Observable list to store names
|
||||
private final ObservableList<String> items = FXCollections.observableArrayList();
|
||||
|
||||
@FXML
|
||||
private Button add;
|
||||
|
||||
@FXML
|
||||
private TextField input;
|
||||
|
||||
@FXML
|
||||
private ListView<String> list; // ListView configured to display Strings
|
||||
|
||||
@FXML
|
||||
private Button rm;
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
items.add("Homer");
|
||||
items.add("Bart");
|
||||
items.add("Lisa");
|
||||
items.add("Maggi");
|
||||
items.add("Marge");
|
||||
list.setItems(items);
|
||||
}
|
||||
|
||||
@FXML
|
||||
void add(ActionEvent event) {
|
||||
String temp = input.getText().trim();
|
||||
if (!temp.isEmpty() && !items.contains(temp)) { // Avoid duplicates
|
||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||
alert.setTitle("Confirmation Dialog");
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText("Are you sure you want to add " + temp + " from the list?");
|
||||
alert.showAndWait();
|
||||
if (alert.getResult() == ButtonType.OK) {
|
||||
items.add(temp);
|
||||
input.clear(); // Clear the input field after adding
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
void remove(ActionEvent event) {
|
||||
String selected = list.getSelectionModel().getSelectedItem();
|
||||
if (selected != null) {
|
||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||
alert.setTitle("Confirmation Dialog");
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText("Are you sure you want to remove " + selected + " from the list?");
|
||||
alert.showAndWait();
|
||||
|
||||
if (alert.getResult() == ButtonType.OK) {
|
||||
items.remove(selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.example;
|
||||
|
||||
import java.io.IOException;
|
||||
import javafx.fxml.FXML;
|
||||
|
||||
public class SecondaryController {
|
||||
|
||||
@FXML
|
||||
private void switchToPrimary() throws IOException {
|
||||
App.setRoot("primary");
|
||||
}
|
||||
}
|
7
Code/ost/_11_simpson-list/src/main/java/module-info.java
Normal file
7
Code/ost/_11_simpson-list/src/main/java/module-info.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
module com.example {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
|
||||
opens com.example to javafx.fxml;
|
||||
exports com.example;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<GridPane hgap="20.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" vgap="20.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.PrimaryController">
|
||||
|
||||
<!-- Column Configuration -->
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="469.0" minWidth="10.0" prefWidth="469.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="291.0" minWidth="10.0" prefWidth="131.0" />
|
||||
</columnConstraints>
|
||||
|
||||
<!-- Row Configuration -->
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="128.0" minHeight="10.0" prefHeight="25.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="242.0" minHeight="10.0" prefHeight="242.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
|
||||
<!-- GridPane Content -->
|
||||
<children>
|
||||
<!-- Label -->
|
||||
<Label text="Simpson">
|
||||
<font>
|
||||
<Font size="37.0" />
|
||||
</font></Label>
|
||||
|
||||
<!-- Buttons -->
|
||||
<Button fx:id="rm" mnemonicParsing="false" onAction="#remove" text="Remove" textAlignment="CENTER" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="BOTTOM" />
|
||||
|
||||
<Button fx:id="add" mnemonicParsing="false" onAction="#add" text="Add" textAlignment="CENTER" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
|
||||
|
||||
<!-- ListView -->
|
||||
<ListView fx:id="list" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1" />
|
||||
|
||||
<!-- TextField -->
|
||||
<TextField fx:id="input" GridPane.rowIndex="2" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
</GridPane>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
|
||||
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.SecondaryController">
|
||||
<children>
|
||||
<Label text="Secondary View" />
|
||||
<Button fx:id="secondaryButton" text="Switch to Primary View" onAction="#switchToPrimary" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
||||
</padding>
|
||||
</VBox>
|
BIN
Code/ost/_11_simpson-list/target/classes/com/example/App.class
Normal file
BIN
Code/ost/_11_simpson-list/target/classes/com/example/App.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<GridPane hgap="20.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" vgap="20.0" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.PrimaryController">
|
||||
|
||||
<!-- Column Configuration -->
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="469.0" minWidth="10.0" prefWidth="469.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="291.0" minWidth="10.0" prefWidth="131.0" />
|
||||
</columnConstraints>
|
||||
|
||||
<!-- Row Configuration -->
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="128.0" minHeight="10.0" prefHeight="25.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="242.0" minHeight="10.0" prefHeight="242.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
|
||||
<!-- GridPane Content -->
|
||||
<children>
|
||||
<!-- Label -->
|
||||
<Label text="Simpson">
|
||||
<font>
|
||||
<Font size="37.0" />
|
||||
</font></Label>
|
||||
|
||||
<!-- Buttons -->
|
||||
<Button fx:id="rm" mnemonicParsing="false" onAction="#remove" text="Remove" textAlignment="CENTER" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="BOTTOM" />
|
||||
|
||||
<Button fx:id="add" mnemonicParsing="false" onAction="#add" text="Add" textAlignment="CENTER" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2" />
|
||||
|
||||
<!-- ListView -->
|
||||
<ListView fx:id="list" prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1" />
|
||||
|
||||
<!-- TextField -->
|
||||
<TextField fx:id="input" GridPane.rowIndex="2" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
</GridPane>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
|
||||
<VBox alignment="CENTER" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.SecondaryController">
|
||||
<children>
|
||||
<Label text="Secondary View" />
|
||||
<Button fx:id="secondaryButton" text="Switch to Primary View" onAction="#switchToPrimary" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
|
||||
</padding>
|
||||
</VBox>
|
BIN
Code/ost/_11_simpson-list/target/classes/module-info.class
Normal file
BIN
Code/ost/_11_simpson-list/target/classes/module-info.class
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue