Added flashcard project that implements the arrow buttons

This commit is contained in:
top19 2020-04-19 16:37:24 +01:00
parent 630f089ac0
commit fbde4e6ec4
20 changed files with 77 additions and 32 deletions

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/hellofx.iml" filepath="$PROJECT_DIR$/.idea/hellofx.iml" />
</modules>
</component>
</project>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../../../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
</project> </project>

View 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>

View file

@ -155,8 +155,8 @@
</option> </option>
</component> </component>
<component name="ProjectFrameBounds" extendedState="6"> <component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="343" /> <option name="x" value="196" />
<option name="y" value="113" /> <option name="y" value="75" />
<option name="width" value="1400" /> <option name="width" value="1400" />
<option name="height" value="1000" /> <option name="height" value="1000" />
</component> </component>
@ -264,7 +264,7 @@
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="last_opened_file_path" value="M:/Year2/JsonTest1.1/JsonTest1.1" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="project.structure.last.edited" value="Project" /> <property name="project.structure.last.edited" value="Project" />
<property name="project.structure.proportion" value="0.15" /> <property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.0" /> <property name="project.structure.side.proportion" value="0.0" />

View file

@ -9,7 +9,7 @@
<maven.compiler.release>11</maven.compiler.release> <maven.compiler.release>11</maven.compiler.release>
<javafx.version>13</javafx.version> <javafx.version>13</javafx.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.openjfx</groupId> <groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId> <artifactId>javafx-controls</artifactId>

View file

@ -4,9 +4,10 @@ public class WelshDictionary {
private String english; private String english;
private String welsh; private String welsh;
private String wordType; private String wordType;
private boolean practiceWord;
public WelshDictionary() { public WelshDictionary() {
practiceWord = false;
} }
public WelshDictionary(String english, String welsh, String wordType) { public WelshDictionary(String english, String welsh, String wordType) {
@ -39,6 +40,14 @@ public class WelshDictionary {
this.wordType = wordType; this.wordType = wordType;
} }
public boolean isPracticeWord() {
return practiceWord;
}
public void setPracticeWord(boolean practiceWord) {
this.practiceWord = practiceWord;
}
@Override @Override
public String toString() { public String toString() {
return "WelshDictionary{" + return "WelshDictionary{" +

View file

@ -2,12 +2,10 @@ package org.openjfx.javaFX;
import javafx.application.Application; import javafx.application.Application;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import jsonStuff.JsonProcessing; import jsonStuff.JsonProcessing;
import jsonStuff.WelshDictionary; import jsonStuff.WelshDictionary;

View file

@ -3,13 +3,12 @@ package org.openjfx.javaFX;
import javafx.animation.*; import javafx.animation.*;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import javafx.scene.transform.Rotate; import javafx.scene.transform.Rotate;
import javafx.util.Duration; import javafx.util.Duration;
import jsonStuff.WelshDictionary;
import java.util.Stack;
public class PrimaryController { public class PrimaryController {
int index = 0; int index = 0;
@ -24,6 +23,11 @@ public class PrimaryController {
@FXML @FXML
private Text testWord; private Text testWord;
@FXML
private ImageView left_arrow;
@FXML
private ImageView right_arrow;
@FXML @FXML
private void initialize() { private void initialize() {
testWord.setText(App.words.getFirst().getWelsh()); testWord.setText(App.words.getFirst().getWelsh());
@ -31,6 +35,12 @@ public class PrimaryController {
updateCounter(); updateCounter();
card = flashcard; card = flashcard;
Image left = new Image(getClass().getResource("/assets/docs_ui_spec_presentation_src_img_Icons_icons8-left-50.png").toExternalForm());
Image right = new Image(getClass().getResourceAsStream("/assets/docs_ui_spec_presentation_src_img_Icons_icons8-right-50.png"));
left_arrow.setImage(left);
right_arrow.setImage(right);
} }
@FXML @FXML

View file

@ -1,43 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?> <?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<?import javafx.scene.shape.Rectangle?> <?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.shape.Line?> <?import javafx.scene.image.ImageView?>
<?import javafx.scene.shape.Polygon?>
<VBox xmlns:fx="http://javafx.com/fxml" <VBox xmlns:fx="http://javafx.com/fxml"
fx:controller="org.openjfx.javaFX.PrimaryController" alignment="center" spacing="10"> stylesheets="@styles.css" fx:controller="org.openjfx.javaFX.PrimaryController" alignment="center" spacing="10">
<padding> <padding>
<Insets top="25" right="25" bottom="10" left="25"/> <Insets top="25" right="25" bottom="10" left="25"/>
</padding> </padding>
<children> <children>
<StackPane onMouseClicked="#handleFlashcardClick"> <StackPane onMouseClicked="#handleFlashcardClick">
<children> <children>
<Rectangle fx:id="flashcard" width="500" height="360" fill="white" arcHeight="80" arcWidth="80" <Rectangle fx:id="flashcard" width="550" height="360" fill="white" arcHeight="80" arcWidth="80"
stroke="black"/> stroke="black"/>
<Text textAlignment="CENTER" fx:id="testWord"> <Text textAlignment="CENTER" fx:id="testWord">
<font> <font>
<Font size="50"/> <Font size="55"/>
</font> </font>
</Text> </Text>
<VBox alignment="BOTTOM_CENTER"> <VBox alignment="BOTTOM_CENTER">
<Text fx:id="wordType" fill="dimgray"> <Text fx:id="wordType" fill="dimgray">
<font> <font>
<Font size="15"></Font> <Font size="20"></Font>
</font> </font>
</Text> </Text>
</VBox> </VBox>
</children> </children>
</StackPane> </StackPane>
<HBox spacing="75" alignment="BASELINE_CENTER"> <HBox spacing="190" alignment="BASELINE_CENTER">
<children> <children>
<Button text="Previous" onAction="#handlePreviousCard"></Button> <ImageView fx:id="left_arrow" visible="true" onMouseClicked="#handlePreviousCard"></ImageView>
<Text fx:id="counter"/> <Text fx:id="counter"><font> <Font size = "20"></Font></font></Text>
<Button text="Next" onAction="#handleNextCard"></Button> <ImageView fx:id="right_arrow" onMouseClicked="#handleNextCard"></ImageView>
</children> </children>
</HBox> </HBox>
</children> </children>

View file

@ -1,3 +1,7 @@
.button { .button {
-fx-text-fill: blue; -fx-text-fill: blue;
} }
#counter {
-fx-text-fill: blue;
}

View file

@ -1,43 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?> <?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<?import javafx.scene.shape.Rectangle?> <?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.shape.Line?> <?import javafx.scene.image.ImageView?>
<?import javafx.scene.shape.Polygon?>
<VBox xmlns:fx="http://javafx.com/fxml" <VBox xmlns:fx="http://javafx.com/fxml"
fx:controller="org.openjfx.javaFX.PrimaryController" alignment="center" spacing="10"> stylesheets="@styles.css" fx:controller="org.openjfx.javaFX.PrimaryController" alignment="center" spacing="10">
<padding> <padding>
<Insets top="25" right="25" bottom="10" left="25"/> <Insets top="25" right="25" bottom="10" left="25"/>
</padding> </padding>
<children> <children>
<StackPane onMouseClicked="#handleFlashcardClick"> <StackPane onMouseClicked="#handleFlashcardClick">
<children> <children>
<Rectangle fx:id="flashcard" width="500" height="360" fill="white" arcHeight="80" arcWidth="80" <Rectangle fx:id="flashcard" width="550" height="360" fill="white" arcHeight="80" arcWidth="80"
stroke="black"/> stroke="black"/>
<Text textAlignment="CENTER" fx:id="testWord"> <Text textAlignment="CENTER" fx:id="testWord">
<font> <font>
<Font size="50"/> <Font size="55"/>
</font> </font>
</Text> </Text>
<VBox alignment="BOTTOM_CENTER"> <VBox alignment="BOTTOM_CENTER">
<Text fx:id="wordType" fill="dimgray"> <Text fx:id="wordType" fill="dimgray">
<font> <font>
<Font size="15"></Font> <Font size="20"></Font>
</font> </font>
</Text> </Text>
</VBox> </VBox>
</children> </children>
</StackPane> </StackPane>
<HBox spacing="75" alignment="BASELINE_CENTER"> <HBox spacing="190" alignment="BASELINE_CENTER">
<children> <children>
<Button text="Previous" onAction="#handlePreviousCard"></Button> <ImageView fx:id="left_arrow" visible="true" onMouseClicked="#handlePreviousCard"></ImageView>
<Text fx:id="counter"/> <Text fx:id="counter"><font> <Font size = "20"></Font></font></Text>
<Button text="Next" onAction="#handleNextCard"></Button> <ImageView fx:id="right_arrow" onMouseClicked="#handleNextCard"></ImageView>
</children> </children>
</HBox> </HBox>
</children> </children>

View file

@ -1,3 +1,7 @@
.button { .button {
-fx-text-fill: blue; -fx-text-fill: blue;
} }
#counter {
-fx-text-fill: blue;
}