Added 'exercise' + menu :hover

This commit is contained in:
xdrm-brackets 2017-12-19 18:09:03 +01:00
parent 98982bc1fc
commit bab2d19601
3 changed files with 91 additions and 12 deletions

View File

@ -39,6 +39,7 @@ public class RootLayout extends Application implements EventObserver {
private Scene root_scene; private Scene root_scene;
private AnchorPane root_layout; private AnchorPane root_layout;
private FlowPane main_container; private FlowPane main_container;
private VBox main_menu;
private Article articles; private Article articles;
private Traduction dico; private Traduction dico;
@ -153,8 +154,8 @@ public class RootLayout extends Application implements EventObserver {
this.root_stage.setScene(this.root_scene); this.root_stage.setScene(this.root_scene);
//bind events on click fot the menu //bind events on click fot the menu
VBox menuRoot = (VBox) this.root_layout.lookup("#menu"); this.main_menu = (VBox) this.root_layout.lookup("#menu");
for (Node c : menuRoot.getChildren()) { for (Node c : this.main_menu.getChildren()) {
c.setOnMousePressed(new EventHandler<MouseEvent>() { c.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override @Override
public void handle(MouseEvent event) { public void handle(MouseEvent event) {
@ -257,16 +258,37 @@ public class RootLayout extends Application implements EventObserver {
public void handleMainLayoutChange(String layout) { public void handleMainLayoutChange(String layout) {
this.main_container.getChildren().clear(); this.main_container.getChildren().clear();
FXMLLoader loader;
/* Un-select all menu items but re-select the chosen one */
for( Node n : this.main_menu.getChildren() ){
n.getStyleClass().clear();
n.getStyleClass().add("menu_item");
if( n.getId() == layout )
n.getStyleClass().add("active");
}
switch(layout) { switch(layout) {
case "dictionary" : case "dictionary" :
this.main_container.getChildren().add(new Text("dictionary")); /* (1) Load the root_disp.fxml */
loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/fxml/vocabulary_disp.fxml"));
/* (2) Load the layout into the scene */
try {
this.main_container.getChildren().add((AnchorPane) loader.load());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
break; break;
case "exercises" : case "exercises" :
/* (1) Load the root_disp.fxml */ /* (1) Load the root_disp.fxml */
FXMLLoader loader = new FXMLLoader(); loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/fxml/vocabulary_disp.fxml")); loader.setLocation(getClass().getResource("/fxml/exercise_disp.fxml"));
/* (2) Load the layout into the scene */ /* (2) Load the layout into the scene */
try { try {

View File

@ -36,6 +36,10 @@
-fx-border-color: #eeeeee; -fx-border-color: #eeeeee;
} }
.menu_item.active{
-fx-background-color: #eeeeee;
}
#menu{ #menu{
-fx-background-color: #ffffff; -fx-background-color: #ffffff;

53
fxml/exercise_disp.fxml Normal file
View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Text?>
<AnchorPane id="exerc" fx:id="exerc" prefHeight="228.0" prefWidth="620.0" style="-fx-border-insets: 10; -fx-background-insets: 10; -fx-background-color: #ffffff; -fx-background-radius: 3; -fx-border-radius: 3; -fx-border-color: #ddd;" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1">
<opaqueInsets>
<Insets />
</opaqueInsets>
<children>
<Text layoutX="251.0" layoutY="39.0" strokeType="OUTSIDE" strokeWidth="0.0" style="-fx-font-size: 20;" text="Exercise #1" />
<Button layoutX="536.0" layoutY="194.0" mnemonicParsing="false" style="-fx-background-color: #ffffff; -fx-border-width: 1; -fx-border-color: #aaaaaa; -fx-text-fill: #000000; -fx-border-radius: 3; -fx-background-radius: 3;" text="Check" />
<Text layoutX="47.0" layoutY="96.0" strokeType="OUTSIDE" strokeWidth="0.0" text="&quot;I am doing my homework&quot; is affirmative" />
<Text layoutX="47.0" layoutY="118.0" strokeType="OUTSIDE" strokeWidth="0.0" />
<Text layoutX="105.0" layoutY="129.0" strokeType="OUTSIDE" strokeWidth="0.0" text="&quot;Where do you live ?&quot; is passive" />
<Text layoutX="33.0" layoutY="161.0" strokeType="OUTSIDE" strokeWidth="0.0" text="&quot;She had a nightmare&quot; happens in the past" />
<Text layoutX="59.0" layoutY="191.0" strokeType="OUTSIDE" strokeWidth="0.0" text="&quot;She had a dream ?&quot; is a valid question" />
<Text layoutX="317.0" layoutY="67.0" strokeType="OUTSIDE" strokeWidth="0.0" text="True" />
<Text layoutX="352.0" layoutY="68.0" strokeType="OUTSIDE" strokeWidth="0.0" text="False" />
<RadioButton layoutX="327.0" layoutY="83.0" mnemonicParsing="false" selected="true">
<toggleGroup>
<ToggleGroup fx:id="g1" />
</toggleGroup>
</RadioButton>
<RadioButton layoutX="353.0" layoutY="83.0" mnemonicParsing="false" toggleGroup="$g1" />
<RadioButton layoutX="327.0" layoutY="117.0" mnemonicParsing="false" selected="true">
<toggleGroup>
<ToggleGroup fx:id="g2" />
</toggleGroup>
</RadioButton>
<RadioButton layoutX="353.0" layoutY="117.0" mnemonicParsing="false" toggleGroup="$g2" />
<RadioButton layoutX="327.0" layoutY="148.0" mnemonicParsing="false" selected="true">
<toggleGroup>
<ToggleGroup fx:id="g3" />
</toggleGroup>
</RadioButton>
<RadioButton layoutX="353.0" layoutY="148.0" mnemonicParsing="false" toggleGroup="$g3" />
<RadioButton layoutX="327.0" layoutY="178.0" mnemonicParsing="false" selected="true">
<toggleGroup>
<ToggleGroup fx:id="g4" />
</toggleGroup>
</RadioButton>
<RadioButton layoutX="353.0" layoutY="178.0" mnemonicParsing="false" toggleGroup="$g4" />
</children>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</AnchorPane>