JavaFX work commit
The first commit of the JavaFX work, containing most of the JavaFX experimentation. Git directory in project causing issues with Gitlab, this is now removed and issue fixed.
This commit is contained in:
parent
0203e104b4
commit
d19b4580ae
76 changed files with 1836 additions and 0 deletions
2
dev/20200225/law39/Maven/hellofx/.idea/.gitignore
vendored
Normal file
2
dev/20200225/law39/Maven/hellofx/.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Default ignored files
|
||||
/workspace.xml
|
13
dev/20200225/law39/Maven/hellofx/.idea/compiler.xml
Normal file
13
dev/20200225/law39/Maven/hellofx/.idea/compiler.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="hellofx" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
9
dev/20200225/law39/Maven/hellofx/.idea/encodings.xml
Normal file
9
dev/20200225/law39/Maven/hellofx/.idea/encodings.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
17
dev/20200225/law39/Maven/hellofx/.idea/misc.xml
Normal file
17
dev/20200225/law39/Maven/hellofx/.idea/misc.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_12" default="false" project-jdk-name="13" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
6
dev/20200225/law39/Maven/hellofx/.idea/vcs.xml
Normal file
6
dev/20200225/law39/Maven/hellofx/.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
2
dev/20200225/law39/Maven/hellofx/hellofx.iml
Normal file
2
dev/20200225/law39/Maven/hellofx/hellofx.iml
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
62
dev/20200225/law39/Maven/hellofx/pom.xml
Normal file
62
dev/20200225/law39/Maven/hellofx/pom.xml
Normal file
|
@ -0,0 +1,62 @@
|
|||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>org.openjfx</groupId>
|
||||
<artifactId>hellofx</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.release>11</maven.compiler.release>
|
||||
<javafx.version>13</javafx.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<release>${maven.compiler.release}</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.3</version>
|
||||
<configuration>
|
||||
<release>${maven.compiler.release}</release>
|
||||
<jlinkImageName>hellofx</jlinkImageName>
|
||||
<launcher>launcher</launcher>
|
||||
<mainClass>hellofx/org.openjfx.javaFX.App</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,46 @@
|
|||
package jsonStuff;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class JsonProcessing {
|
||||
|
||||
public LinkedList<WelshDictionary> readInJson(String directoryAndFile) {
|
||||
LinkedList<WelshDictionary> returnVal = new LinkedList<>();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
File file = new File(directoryAndFile);
|
||||
|
||||
try {
|
||||
returnVal.addAll(Arrays.asList(objectMapper.readValue(file, WelshDictionary[].class)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
public void writeOutJson(String directoryAndFile, LinkedList<WelshDictionary> words) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String JsonString = "";
|
||||
|
||||
try {
|
||||
JsonString = objectMapper.writeValueAsString(words);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
Files.writeString(Paths.get(directoryAndFile), JsonString);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package jsonStuff;
|
||||
|
||||
public class WelshDictionary {
|
||||
private String english;
|
||||
private String welsh;
|
||||
private String wordType;
|
||||
|
||||
public WelshDictionary() {
|
||||
}
|
||||
|
||||
public WelshDictionary(String english, String welsh, String wordType) {
|
||||
this.english = english;
|
||||
this.welsh = welsh;
|
||||
this.wordType = wordType;
|
||||
}
|
||||
|
||||
public String getEnglish() {
|
||||
return english;
|
||||
}
|
||||
|
||||
public void setEnglish(String english) {
|
||||
this.english = english;
|
||||
}
|
||||
|
||||
public String getWelsh() {
|
||||
return welsh;
|
||||
}
|
||||
|
||||
public void setWelsh(String welsh) {
|
||||
this.welsh = welsh;
|
||||
}
|
||||
|
||||
public String getWordType() {
|
||||
return wordType;
|
||||
}
|
||||
|
||||
public void setWordType(String wordType) {
|
||||
this.wordType = wordType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WelshDictionary{" +
|
||||
"english='" + english + '\'' +
|
||||
", welsh='" + welsh + '\'' +
|
||||
", wordType='" + wordType + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
module hellofx {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
requires com.fasterxml.jackson.databind;
|
||||
requires com.fasterxml.jackson.core;
|
||||
|
||||
opens org.openjfx.javaFX to javafx.fxml;
|
||||
exports org.openjfx.javaFX;
|
||||
|
||||
opens jsonStuff to com.fasterxml.jackson.databind;
|
||||
exports jsonStuff;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package org.openjfx.javaFX;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import jsonStuff.JsonProcessing;
|
||||
import jsonStuff.WelshDictionary;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* JavaFX App
|
||||
*/
|
||||
public class App extends Application {
|
||||
|
||||
public static LinkedList<WelshDictionary> words = new LinkedList<>();
|
||||
private static Scene scene;
|
||||
private JsonProcessing jsonProcessing = new JsonProcessing();
|
||||
private Scanner scanner = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
System.out.println("Where is the Json file?");
|
||||
String jsonFileLocation = scanner.next();
|
||||
words = jsonProcessing.readInJson(jsonFileLocation);
|
||||
|
||||
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
|
||||
primaryStage.setTitle("Hello World");
|
||||
primaryStage.setScene(new Scene(root, 300, 275));
|
||||
|
||||
primaryStage.setOnCloseRequest(e -> {
|
||||
jsonProcessing.writeOutJson(jsonFileLocation, words);
|
||||
Platform.exit();
|
||||
System.exit(0);
|
||||
});
|
||||
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.openjfx.javaFX;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.TextField;
|
||||
import jsonStuff.WelshDictionary;
|
||||
|
||||
public class PrimaryController {
|
||||
|
||||
@FXML
|
||||
private TextField welsh;
|
||||
@FXML
|
||||
private TextField english;
|
||||
@FXML
|
||||
private TextField wordType;
|
||||
|
||||
|
||||
@FXML
|
||||
protected void addButtonClick(ActionEvent actionEvent) {
|
||||
App.words.add(new WelshDictionary(english.getText(), welsh.getText(), wordType.getText()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Your Welsh word: ").append(welsh.getText()).append("\n");
|
||||
sb.append("With English translation: ").append(english.getText()).append("\n");
|
||||
sb.append("Has been added to the dictionary.");
|
||||
|
||||
english.setText("");
|
||||
welsh.setText("");
|
||||
wordType.setText("");
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information Dialog");
|
||||
alert.setHeaderText("Entry added");
|
||||
alert.setContentText(sb.toString());
|
||||
|
||||
alert.showAndWait();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="org.openjfx.javaFX.PrimaryController" alignment="center" hgap="10" vgap="10">
|
||||
<padding>
|
||||
<Insets top="25" right="25" bottom="10" left="25"/>
|
||||
</padding>
|
||||
|
||||
<Text text="This is a demo to add welsh words to the JSON file"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="0"
|
||||
GridPane.columnSpan="2"/>
|
||||
|
||||
<Label text="Welsh word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||
|
||||
<TextField
|
||||
fx:id="welsh"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="English Word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
|
||||
<TextField
|
||||
fx:id="english"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
|
||||
<Label text="Word Type:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
|
||||
|
||||
<TextField
|
||||
fx:id="wordType"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
|
||||
<HBox spacing="10" alignment="bottom_right"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="4">
|
||||
<Button text="Add word to dictionary"
|
||||
onAction="#addButtonClick"/>
|
||||
</HBox>
|
||||
|
||||
|
||||
</GridPane>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
.button {
|
||||
-fx-text-fill: blue;
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<GridPane xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="org.openjfx.javaFX.PrimaryController" alignment="center" hgap="10" vgap="10">
|
||||
<padding>
|
||||
<Insets top="25" right="25" bottom="10" left="25"/>
|
||||
</padding>
|
||||
|
||||
<Text text="This is a demo to add welsh words to the JSON file"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="0"
|
||||
GridPane.columnSpan="2"/>
|
||||
|
||||
<Label text="Welsh word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||
|
||||
<TextField
|
||||
fx:id="welsh"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="English Word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
|
||||
<TextField
|
||||
fx:id="english"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
|
||||
<Label text="Word Type:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
|
||||
|
||||
<TextField
|
||||
fx:id="wordType"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
|
||||
<HBox spacing="10" alignment="bottom_right"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="4">
|
||||
<Button text="Add word to dictionary"
|
||||
onAction="#addButtonClick"/>
|
||||
</HBox>
|
||||
|
||||
|
||||
</GridPane>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
.button {
|
||||
-fx-text-fill: blue;
|
||||
}
|
2
dev/20200225/law39/Switch Scenes/hellofx/.idea/.gitignore
vendored
Normal file
2
dev/20200225/law39/Switch Scenes/hellofx/.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Default ignored files
|
||||
/workspace.xml
|
13
dev/20200225/law39/Switch Scenes/hellofx/.idea/compiler.xml
Normal file
13
dev/20200225/law39/Switch Scenes/hellofx/.idea/compiler.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="hellofx" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
17
dev/20200225/law39/Switch Scenes/hellofx/.idea/misc.xml
Normal file
17
dev/20200225/law39/Switch Scenes/hellofx/.idea/misc.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_12" default="false" project-jdk-name="13" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
6
dev/20200225/law39/Switch Scenes/hellofx/.idea/vcs.xml
Normal file
6
dev/20200225/law39/Switch Scenes/hellofx/.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
2
dev/20200225/law39/Switch Scenes/hellofx/hellofx.iml
Normal file
2
dev/20200225/law39/Switch Scenes/hellofx/hellofx.iml
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
62
dev/20200225/law39/Switch Scenes/hellofx/pom.xml
Normal file
62
dev/20200225/law39/Switch Scenes/hellofx/pom.xml
Normal file
|
@ -0,0 +1,62 @@
|
|||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>org.openjfx</groupId>
|
||||
<artifactId>hellofx</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.release>11</maven.compiler.release>
|
||||
<javafx.version>13</javafx.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<release>${maven.compiler.release}</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.3</version>
|
||||
<configuration>
|
||||
<release>${maven.compiler.release}</release>
|
||||
<jlinkImageName>hellofx</jlinkImageName>
|
||||
<launcher>launcher</launcher>
|
||||
<mainClass>hellofx/org.openjfx.javaFX.App</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,45 @@
|
|||
package jsonStuff;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class JsonProcessing {
|
||||
|
||||
public LinkedList<WelshDictionary> readInJson(File file) {
|
||||
LinkedList<WelshDictionary> returnVal = new LinkedList<>();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
returnVal.addAll(Arrays.asList(objectMapper.readValue(file, WelshDictionary[].class)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
public void writeOutJson(File directoryAndFile, LinkedList<WelshDictionary> words){
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String JsonString = "";
|
||||
|
||||
try {
|
||||
JsonString = objectMapper.writeValueAsString(words);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
Files.writeString(Paths.get(String.valueOf(directoryAndFile)), JsonString);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package jsonStuff;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WelshDictionary {
|
||||
private String english;
|
||||
private String welsh;
|
||||
private String wordType;
|
||||
|
||||
public WelshDictionary(){}
|
||||
|
||||
|
||||
|
||||
public WelshDictionary(String english, String welsh, String wordType) {
|
||||
this.english = english;
|
||||
this.welsh = welsh;
|
||||
this.wordType = wordType;
|
||||
}
|
||||
|
||||
public WelshDictionary(String english, String welsh){
|
||||
this.english = english;
|
||||
this.welsh = welsh;
|
||||
}
|
||||
|
||||
public String getEnglish() {
|
||||
return english;
|
||||
}
|
||||
|
||||
public void setEnglish(String english) {
|
||||
this.english = english;
|
||||
}
|
||||
|
||||
public String getWelsh() {
|
||||
return welsh;
|
||||
}
|
||||
|
||||
public void setWelsh(String welsh) {
|
||||
this.welsh = welsh;
|
||||
}
|
||||
|
||||
public String getWordType() {
|
||||
return wordType;
|
||||
}
|
||||
|
||||
public void setWordType(String wordType) {
|
||||
this.wordType = wordType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WelshDictionary{" +
|
||||
"english='" + english + '\'' +
|
||||
", welsh='" + welsh + '\'' +
|
||||
", wordType='" + wordType + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
WelshDictionary that = (WelshDictionary) o;
|
||||
return english.equals(that.english) &&
|
||||
welsh.equals(that.welsh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(english, welsh, wordType);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
module hellofx {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
requires com.fasterxml.jackson.databind;
|
||||
requires com.fasterxml.jackson.core;
|
||||
|
||||
|
||||
opens org.openjfx.javaFX to javafx.fxml;
|
||||
exports org.openjfx.javaFX;
|
||||
|
||||
opens jsonStuff to com.fasterxml.jackson.databind;
|
||||
exports jsonStuff;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package org.openjfx.javaFX;
|
||||
|
||||
import jsonStuff.WelshDictionary;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class AddController {
|
||||
|
||||
@FXML private TextField welsh;
|
||||
@FXML private TextField english;
|
||||
@FXML private TextField wordType;
|
||||
private Scene secondScene;
|
||||
|
||||
|
||||
@FXML protected void addButtonClick(ActionEvent actionEvent) {
|
||||
App.words.add(new WelshDictionary(english.getText(),welsh.getText(),wordType.getText()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Your Welsh word: ").append(welsh.getText()).append("\n");
|
||||
sb.append("With English translation: ").append(english.getText()).append("\n");
|
||||
sb.append("Has been added to the dictionary.");
|
||||
|
||||
english.setText("");
|
||||
welsh.setText("");
|
||||
wordType.setText("");
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information Dialog");
|
||||
alert.setHeaderText("Entry added");
|
||||
alert.setContentText(sb.toString());
|
||||
|
||||
alert.showAndWait();
|
||||
|
||||
}
|
||||
|
||||
public void switchScene(ActionEvent actionEvent) {
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information Dialog");
|
||||
alert.setHeaderText("Scene switched");
|
||||
|
||||
alert.showAndWait();
|
||||
|
||||
Stage primaryStage = (Stage)((Node)actionEvent.getSource()).getScene().getWindow();
|
||||
primaryStage.setScene(secondScene);
|
||||
}
|
||||
|
||||
public void setSecondScene(Scene scene) {
|
||||
secondScene = scene;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package org.openjfx.javaFX;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import jsonStuff.JsonProcessing;
|
||||
import jsonStuff.WelshDictionary;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* JavaFX App
|
||||
*/
|
||||
public class App extends Application {
|
||||
|
||||
public static LinkedList<WelshDictionary> words = new LinkedList<>();
|
||||
private static Scene scene;
|
||||
private JsonProcessing jsonProcessing = new JsonProcessing();
|
||||
private Scanner scanner = new Scanner(System.in);
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
FXMLLoader firstPaneLoader = new FXMLLoader(getClass().getResource("add.fxml"));
|
||||
Parent firstPane = firstPaneLoader.load();
|
||||
Scene firstScene = new Scene(firstPane, 1000, 750);
|
||||
|
||||
FXMLLoader secondPageLoader = new FXMLLoader(getClass().getResource("remove.fxml"));
|
||||
Parent secondPane = secondPageLoader.load();
|
||||
Scene secondScene = new Scene(secondPane, 1000, 750);
|
||||
|
||||
|
||||
|
||||
AddController firstPaneController = firstPaneLoader.getController();
|
||||
firstPaneController.setSecondScene(secondScene);
|
||||
|
||||
RemoveController secondPaneController = secondPageLoader.getController();
|
||||
secondPaneController.setFirstScene(firstScene);
|
||||
|
||||
primaryStage.setTitle("Hello World");
|
||||
primaryStage.setScene(firstScene);
|
||||
primaryStage.show();
|
||||
|
||||
File jsonFileLocation = null;
|
||||
|
||||
while(jsonFileLocation ==null) {
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Json Files", "*.json"));
|
||||
fileChooser.setTitle("Open Json File");
|
||||
jsonFileLocation = fileChooser.showOpenDialog(primaryStage);
|
||||
}
|
||||
|
||||
final File jsonFileFinalLocation = jsonFileLocation;
|
||||
|
||||
words = jsonProcessing.readInJson(jsonFileFinalLocation);
|
||||
|
||||
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||
@Override
|
||||
public void handle(WindowEvent e) {
|
||||
jsonProcessing.writeOutJson(jsonFileFinalLocation,words);
|
||||
Platform.exit();
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.openjfx.javaFX;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.TextField;
|
||||
import jsonStuff.WelshDictionary;
|
||||
|
||||
public class PrimaryController {
|
||||
|
||||
@FXML
|
||||
private TextField welsh;
|
||||
@FXML
|
||||
private TextField english;
|
||||
@FXML
|
||||
private TextField wordType;
|
||||
|
||||
|
||||
@FXML
|
||||
protected void addButtonClick(ActionEvent actionEvent) {
|
||||
App.words.add(new WelshDictionary(english.getText(), welsh.getText(), wordType.getText()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Your Welsh word: ").append(welsh.getText()).append("\n");
|
||||
sb.append("With English translation: ").append(english.getText()).append("\n");
|
||||
sb.append("Has been added to the dictionary.");
|
||||
|
||||
english.setText("");
|
||||
welsh.setText("");
|
||||
wordType.setText("");
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information Dialog");
|
||||
alert.setHeaderText("Entry added");
|
||||
alert.setContentText(sb.toString());
|
||||
|
||||
alert.showAndWait();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package org.openjfx.javaFX;
|
||||
|
||||
import jsonStuff.WelshDictionary;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.Stage;
|
||||
import org.openjfx.javaFX.App;
|
||||
|
||||
public class RemoveController {
|
||||
|
||||
@FXML private TextField welsh;
|
||||
@FXML private TextField english;
|
||||
private Scene firstScene;
|
||||
|
||||
|
||||
@FXML protected void removeButtonClick(ActionEvent actionEvent) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Your Welsh word: ").append(welsh.getText()).append("\n");
|
||||
sb.append("With English translation: ").append(english.getText()).append("\n");
|
||||
|
||||
if (App.words.remove(new WelshDictionary(english.getText(), welsh.getText())))
|
||||
sb.append("Has been removed from the dictionary.");
|
||||
else
|
||||
sb.append("Has not been removed from the dictionary.");
|
||||
|
||||
english.setText("");
|
||||
welsh.setText("");
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information Dialog");
|
||||
alert.setHeaderText("Entry added");
|
||||
alert.setContentText(sb.toString());
|
||||
|
||||
alert.showAndWait();
|
||||
|
||||
}
|
||||
|
||||
public void switchScene(ActionEvent actionEvent) {
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information Dialog");
|
||||
alert.setHeaderText("Scene switched");
|
||||
|
||||
alert.showAndWait();
|
||||
Stage primaryStage = (Stage)((Node)actionEvent.getSource()).getScene().getWindow();
|
||||
primaryStage.setScene(firstScene);
|
||||
}
|
||||
|
||||
public void setFirstScene(Scene scene) {
|
||||
firstScene = scene;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<GridPane fx:controller="org.openjfx.javaFX.AddController"
|
||||
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
|
||||
<padding><Insets top="25" right="25" bottom="10" left="25"/></padding>
|
||||
|
||||
<Text text="This is a demo to add welsh words to the JSON file"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="0"
|
||||
GridPane.columnSpan="2"/>
|
||||
|
||||
<Label text="Welsh word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||
|
||||
<TextField
|
||||
fx:id="welsh"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="English Word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
|
||||
<TextField
|
||||
fx:id="english"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
|
||||
<Label text="Word Type:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
|
||||
|
||||
<TextField
|
||||
fx:id="wordType"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
|
||||
<HBox spacing="10" alignment="bottom_right"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="4">
|
||||
<Button text="Add word to dictionary"
|
||||
onAction="#addButtonClick"/>
|
||||
</HBox>
|
||||
|
||||
<Button text="Switch Scene"
|
||||
onAction="#switchScene"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="5"/>
|
||||
|
||||
|
||||
|
||||
</GridPane>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<GridPane fx:controller="org.openjfx.javaFX.RemoveController"
|
||||
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
|
||||
<padding><Insets top="25" right="25" bottom="10" left="25"/></padding>
|
||||
|
||||
<Text text="This is a demo to remove welsh words from the JSON file"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="0"
|
||||
GridPane.columnSpan="2"/>
|
||||
|
||||
<Label text="Welsh word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||
|
||||
<TextField
|
||||
fx:id="welsh"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="English Word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
|
||||
<TextField
|
||||
fx:id="english"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
|
||||
|
||||
<HBox spacing="10" alignment="bottom_right"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||
<Button text="Remove word from dictionary"
|
||||
onAction="#removeButtonClick"/>
|
||||
</HBox>
|
||||
<Button text="Switch Scene"
|
||||
onAction="#switchScene"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="4"/>
|
||||
|
||||
|
||||
|
||||
</GridPane>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<GridPane fx:controller="org.openjfx.javaFX.AddController"
|
||||
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
|
||||
<padding><Insets top="25" right="25" bottom="10" left="25"/></padding>
|
||||
|
||||
<Text text="This is a demo to add welsh words to the JSON file"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="0"
|
||||
GridPane.columnSpan="2"/>
|
||||
|
||||
<Label text="Welsh word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||
|
||||
<TextField
|
||||
fx:id="welsh"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="English Word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
|
||||
<TextField
|
||||
fx:id="english"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
|
||||
<Label text="Word Type:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
|
||||
|
||||
<TextField
|
||||
fx:id="wordType"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
|
||||
<HBox spacing="10" alignment="bottom_right"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="4">
|
||||
<Button text="Add word to dictionary"
|
||||
onAction="#addButtonClick"/>
|
||||
</HBox>
|
||||
|
||||
<Button text="Switch Scene"
|
||||
onAction="#switchScene"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="5"/>
|
||||
|
||||
|
||||
|
||||
</GridPane>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<GridPane fx:controller="org.openjfx.javaFX.RemoveController"
|
||||
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
|
||||
<padding><Insets top="25" right="25" bottom="10" left="25"/></padding>
|
||||
|
||||
<Text text="This is a demo to remove welsh words from the JSON file"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="0"
|
||||
GridPane.columnSpan="2"/>
|
||||
|
||||
<Label text="Welsh word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||
|
||||
<TextField
|
||||
fx:id="welsh"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="English Word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
|
||||
<TextField
|
||||
fx:id="english"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
|
||||
|
||||
<HBox spacing="10" alignment="bottom_right"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||
<Button text="Remove word from dictionary"
|
||||
onAction="#removeButtonClick"/>
|
||||
</HBox>
|
||||
<Button text="Switch Scene"
|
||||
onAction="#switchScene"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="4"/>
|
||||
|
||||
|
||||
|
||||
</GridPane>
|
||||
|
2
dev/20200225/law39/Viewpane/hellofx/.idea/.gitignore
vendored
Normal file
2
dev/20200225/law39/Viewpane/hellofx/.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Default ignored files
|
||||
/workspace.xml
|
13
dev/20200225/law39/Viewpane/hellofx/.idea/compiler.xml
Normal file
13
dev/20200225/law39/Viewpane/hellofx/.idea/compiler.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="hellofx" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
9
dev/20200225/law39/Viewpane/hellofx/.idea/encodings.xml
Normal file
9
dev/20200225/law39/Viewpane/hellofx/.idea/encodings.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
17
dev/20200225/law39/Viewpane/hellofx/.idea/misc.xml
Normal file
17
dev/20200225/law39/Viewpane/hellofx/.idea/misc.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_12" default="false" project-jdk-name="13" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
124
dev/20200225/law39/Viewpane/hellofx/.idea/uiDesigner.xml
Normal file
124
dev/20200225/law39/Viewpane/hellofx/.idea/uiDesigner.xml
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
6
dev/20200225/law39/Viewpane/hellofx/.idea/vcs.xml
Normal file
6
dev/20200225/law39/Viewpane/hellofx/.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
2
dev/20200225/law39/Viewpane/hellofx/hellofx.iml
Normal file
2
dev/20200225/law39/Viewpane/hellofx/hellofx.iml
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
62
dev/20200225/law39/Viewpane/hellofx/pom.xml
Normal file
62
dev/20200225/law39/Viewpane/hellofx/pom.xml
Normal file
|
@ -0,0 +1,62 @@
|
|||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>org.openjfx</groupId>
|
||||
<artifactId>hellofx</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.release>11</maven.compiler.release>
|
||||
<javafx.version>13</javafx.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-fxml</artifactId>
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<release>${maven.compiler.release}</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.3</version>
|
||||
<configuration>
|
||||
<release>${maven.compiler.release}</release>
|
||||
<jlinkImageName>hellofx</jlinkImageName>
|
||||
<launcher>launcher</launcher>
|
||||
<mainClass>hellofx/org.openjfx.javaFX.App</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,45 @@
|
|||
package jsonStuff;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class JsonProcessing {
|
||||
|
||||
public LinkedList<WelshDictionary> readInJson(File file) {
|
||||
LinkedList<WelshDictionary> returnVal = new LinkedList<>();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
returnVal.addAll(Arrays.asList(objectMapper.readValue(file, WelshDictionary[].class)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
public void writeOutJson(File directoryAndFile, LinkedList<WelshDictionary> words){
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String JsonString = "";
|
||||
|
||||
try {
|
||||
JsonString = objectMapper.writeValueAsString(words);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
Files.writeString(Paths.get(String.valueOf(directoryAndFile)), JsonString);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package jsonStuff;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class WelshDictionary {
|
||||
private String english;
|
||||
private String welsh;
|
||||
private String wordType;
|
||||
|
||||
public WelshDictionary(){}
|
||||
|
||||
|
||||
|
||||
public WelshDictionary(String english, String welsh, String wordType) {
|
||||
this.english = english;
|
||||
this.welsh = welsh;
|
||||
this.wordType = wordType;
|
||||
}
|
||||
|
||||
public WelshDictionary(String english, String welsh){
|
||||
this.english = english;
|
||||
this.welsh = welsh;
|
||||
}
|
||||
|
||||
public String getEnglish() {
|
||||
return english;
|
||||
}
|
||||
|
||||
public void setEnglish(String english) {
|
||||
this.english = english;
|
||||
}
|
||||
|
||||
public String getWelsh() {
|
||||
return welsh;
|
||||
}
|
||||
|
||||
public void setWelsh(String welsh) {
|
||||
this.welsh = welsh;
|
||||
}
|
||||
|
||||
public String getWordType() {
|
||||
return wordType;
|
||||
}
|
||||
|
||||
public void setWordType(String wordType) {
|
||||
this.wordType = wordType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WelshDictionary{" +
|
||||
"english='" + english + '\'' +
|
||||
", welsh='" + welsh + '\'' +
|
||||
", wordType='" + wordType + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
WelshDictionary that = (WelshDictionary) o;
|
||||
return english.equals(that.english) &&
|
||||
welsh.equals(that.welsh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(english, welsh, wordType);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
module hellofx {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
requires com.fasterxml.jackson.databind;
|
||||
requires com.fasterxml.jackson.core;
|
||||
|
||||
|
||||
opens org.openjfx.javaFX to javafx.fxml;
|
||||
exports org.openjfx.javaFX;
|
||||
|
||||
opens jsonStuff to com.fasterxml.jackson.databind;
|
||||
exports jsonStuff;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package org.openjfx.javaFX;
|
||||
|
||||
import jsonStuff.WelshDictionary;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class AddController {
|
||||
|
||||
@FXML private TextField welsh;
|
||||
@FXML private TextField english;
|
||||
@FXML private TextField wordType;
|
||||
private Scene secondScene;
|
||||
|
||||
|
||||
@FXML protected void addButtonClick(ActionEvent actionEvent) {
|
||||
App.words.add(new WelshDictionary(english.getText(),welsh.getText(),wordType.getText()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Your Welsh word: ").append(welsh.getText()).append("\n");
|
||||
sb.append("With English translation: ").append(english.getText()).append("\n");
|
||||
sb.append("Has been added to the dictionary.");
|
||||
|
||||
english.setText("");
|
||||
welsh.setText("");
|
||||
wordType.setText("");
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information Dialog");
|
||||
alert.setHeaderText("Entry added");
|
||||
alert.setContentText(sb.toString());
|
||||
|
||||
alert.showAndWait();
|
||||
|
||||
}
|
||||
|
||||
public void switchScene(ActionEvent actionEvent) {
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information Dialog");
|
||||
alert.setHeaderText("Scene switched");
|
||||
|
||||
alert.showAndWait();
|
||||
|
||||
Stage primaryStage = (Stage)((Node)actionEvent.getSource()).getScene().getWindow();
|
||||
primaryStage.setScene(secondScene);
|
||||
}
|
||||
|
||||
public void setSecondScene(Scene scene) {
|
||||
secondScene = scene;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package org.openjfx.javaFX;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
import jsonStuff.JsonProcessing;
|
||||
import jsonStuff.WelshDictionary;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* JavaFX App
|
||||
*/
|
||||
public class App extends Application {
|
||||
|
||||
public static LinkedList<WelshDictionary> words = new LinkedList<>();
|
||||
public static Stage primaryStage =null;
|
||||
private static Scene scene;
|
||||
private JsonProcessing jsonProcessing = new JsonProcessing();
|
||||
private Scanner scanner = new Scanner(System.in);
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
FXMLLoader firstPaneLoader = new FXMLLoader(getClass().getResource("add.fxml"));
|
||||
Parent firstPane = firstPaneLoader.load();
|
||||
Scene firstScene = new Scene(firstPane, 1000, 750);
|
||||
|
||||
FXMLLoader secondPageLoader = new FXMLLoader(getClass().getResource("viewBox.fxml"));
|
||||
Parent secondPane = secondPageLoader.load();
|
||||
Scene secondScene = new Scene(secondPane, 1000, 750);
|
||||
|
||||
|
||||
|
||||
AddController firstPaneController = firstPaneLoader.getController();
|
||||
firstPaneController.setSecondScene(secondScene);
|
||||
|
||||
ViewboxController secondPaneController = secondPageLoader.getController();
|
||||
secondPaneController.setFirstScene(firstScene);
|
||||
|
||||
primaryStage.setTitle("Hello World");
|
||||
primaryStage.setScene(firstScene);
|
||||
primaryStage.show();
|
||||
|
||||
File jsonFileLocation = null;
|
||||
|
||||
while(jsonFileLocation ==null) {
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Json Files", "*.json"));
|
||||
fileChooser.setTitle("Open Json File");
|
||||
jsonFileLocation = fileChooser.showOpenDialog(primaryStage);
|
||||
}
|
||||
|
||||
final File jsonFileFinalLocation = jsonFileLocation;
|
||||
|
||||
words = jsonProcessing.readInJson(jsonFileFinalLocation);
|
||||
|
||||
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
|
||||
@Override
|
||||
public void handle(WindowEvent e) {
|
||||
jsonProcessing.writeOutJson(jsonFileFinalLocation,words);
|
||||
Platform.exit();
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.openjfx.javaFX;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.TextField;
|
||||
import jsonStuff.WelshDictionary;
|
||||
|
||||
public class PrimaryController {
|
||||
|
||||
@FXML
|
||||
private TextField welsh;
|
||||
@FXML
|
||||
private TextField english;
|
||||
@FXML
|
||||
private TextField wordType;
|
||||
|
||||
|
||||
@FXML
|
||||
protected void addButtonClick(ActionEvent actionEvent) {
|
||||
App.words.add(new WelshDictionary(english.getText(), welsh.getText(), wordType.getText()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Your Welsh word: ").append(welsh.getText()).append("\n");
|
||||
sb.append("With English translation: ").append(english.getText()).append("\n");
|
||||
sb.append("Has been added to the dictionary.");
|
||||
|
||||
english.setText("");
|
||||
welsh.setText("");
|
||||
wordType.setText("");
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information Dialog");
|
||||
alert.setHeaderText("Entry added");
|
||||
alert.setContentText(sb.toString());
|
||||
|
||||
alert.showAndWait();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package org.openjfx.javaFX;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.cell.ComboBoxListCell;
|
||||
import jsonStuff.WelshDictionary;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.Stage;
|
||||
import org.openjfx.javaFX.App;
|
||||
|
||||
public class ViewboxController {
|
||||
|
||||
public ListView<WelshDictionary> EnglishlistView;
|
||||
@FXML private TextField welsh;
|
||||
@FXML private TextField english;
|
||||
private Scene firstScene;
|
||||
public static final ObservableList<WelshDictionary> names = FXCollections.observableArrayList();
|
||||
public static final ObservableList<WelshDictionary> data = FXCollections.observableArrayList();
|
||||
|
||||
|
||||
public void initialize(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void switchScene(ActionEvent actionEvent) {
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||
alert.setTitle("Information Dialog");
|
||||
alert.setHeaderText("Scene switched");
|
||||
|
||||
alert.showAndWait();
|
||||
Stage primaryStage = (Stage)((Node)actionEvent.getSource()).getScene().getWindow();
|
||||
primaryStage.setScene(firstScene);
|
||||
}
|
||||
|
||||
public void setFirstScene(Scene scene) {
|
||||
firstScene = scene;
|
||||
}
|
||||
|
||||
public void loadList(ActionEvent actionEvent) {
|
||||
EnglishlistView.setOrientation(Orientation.VERTICAL);
|
||||
|
||||
EnglishlistView.setCellFactory(param -> new ListCell<WelshDictionary>() {
|
||||
@Override
|
||||
protected void updateItem(WelshDictionary item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (empty || item == null || item.getEnglish() == null||item.getWelsh() == null || item.getWordType() ==null) {
|
||||
setText(null);
|
||||
} else {
|
||||
setText(item.getEnglish() + " " + item.getWelsh());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
data.addAll(App.words);
|
||||
|
||||
EnglishlistView.setItems(data);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<GridPane fx:controller="org.openjfx.javaFX.AddController"
|
||||
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
|
||||
<padding><Insets top="25" right="25" bottom="10" left="25"/></padding>
|
||||
|
||||
<Text text="This is a demo to add welsh words to the JSON file"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="0"
|
||||
GridPane.columnSpan="2"/>
|
||||
|
||||
<Label text="Welsh word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||
|
||||
<TextField
|
||||
fx:id="welsh"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="English Word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
|
||||
<TextField
|
||||
fx:id="english"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
|
||||
<Label text="Word Type:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
|
||||
|
||||
<TextField
|
||||
fx:id="wordType"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
|
||||
<HBox spacing="10" alignment="bottom_right"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="4">
|
||||
<Button text="Add word to dictionary"
|
||||
onAction="#addButtonClick"/>
|
||||
</HBox>
|
||||
|
||||
<Button text="Switch Scene"
|
||||
onAction="#switchScene"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="5"/>
|
||||
|
||||
|
||||
|
||||
</GridPane>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<GridPane fx:controller="org.openjfx.javaFX.ViewboxController"
|
||||
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
|
||||
<padding><Insets top="25" right="25" bottom="10" left="25"/></padding>
|
||||
|
||||
<Text text="This is a demo to show words in a viewbox"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="0"
|
||||
GridPane.columnSpan="2"/>
|
||||
|
||||
|
||||
|
||||
<ListView fx:id="EnglishlistView"
|
||||
GridPane.columnIndex="0"
|
||||
GridPane.rowIndex="1"
|
||||
GridPane.columnSpan="4"/>
|
||||
|
||||
|
||||
<Button text="Load"
|
||||
onAction="#loadList"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
|
||||
|
||||
<Button text="Switch Scene"
|
||||
onAction="#switchScene"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
|
||||
|
||||
|
||||
|
||||
</GridPane>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<GridPane fx:controller="org.openjfx.javaFX.AddController"
|
||||
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
|
||||
<padding><Insets top="25" right="25" bottom="10" left="25"/></padding>
|
||||
|
||||
<Text text="This is a demo to add welsh words to the JSON file"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="0"
|
||||
GridPane.columnSpan="2"/>
|
||||
|
||||
<Label text="Welsh word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||
|
||||
<TextField
|
||||
fx:id="welsh"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="English Word:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
|
||||
<TextField
|
||||
fx:id="english"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
|
||||
<Label text="Word Type:"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
|
||||
|
||||
<TextField
|
||||
fx:id="wordType"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
|
||||
<HBox spacing="10" alignment="bottom_right"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="4">
|
||||
<Button text="Add word to dictionary"
|
||||
onAction="#addButtonClick"/>
|
||||
</HBox>
|
||||
|
||||
<Button text="Switch Scene"
|
||||
onAction="#switchScene"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="5"/>
|
||||
|
||||
|
||||
|
||||
</GridPane>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<GridPane fx:controller="org.openjfx.javaFX.ViewboxController"
|
||||
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
|
||||
<padding><Insets top="25" right="25" bottom="10" left="25"/></padding>
|
||||
|
||||
<Text text="This is a demo to show words in a viewbox"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="0"
|
||||
GridPane.columnSpan="2"/>
|
||||
|
||||
|
||||
|
||||
<ListView fx:id="EnglishlistView"
|
||||
GridPane.columnIndex="0"
|
||||
GridPane.rowIndex="1"
|
||||
GridPane.columnSpan="4"/>
|
||||
|
||||
|
||||
<Button text="Load"
|
||||
onAction="#loadList"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
|
||||
|
||||
<Button text="Switch Scene"
|
||||
onAction="#switchScene"
|
||||
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
|
||||
|
||||
|
||||
|
||||
</GridPane>
|
||||
|
Reference in a new issue