diff --git a/controller/RootLayout.java b/controller/RootLayout.java index a83ef30..2923f77 100644 --- a/controller/RootLayout.java +++ b/controller/RootLayout.java @@ -39,6 +39,7 @@ public class RootLayout extends Application implements EventObserver { private Scene root_scene; private AnchorPane root_layout; private FlowPane main_container; + private VBox main_menu; private Article articles; private Traduction dico; @@ -153,8 +154,8 @@ public class RootLayout extends Application implements EventObserver { this.root_stage.setScene(this.root_scene); //bind events on click fot the menu - VBox menuRoot = (VBox) this.root_layout.lookup("#menu"); - for (Node c : menuRoot.getChildren()) { + this.main_menu = (VBox) this.root_layout.lookup("#menu"); + for (Node c : this.main_menu.getChildren()) { c.setOnMousePressed(new EventHandler() { @Override public void handle(MouseEvent event) { @@ -257,24 +258,45 @@ public class RootLayout extends Application implements EventObserver { public void handleMainLayoutChange(String layout) { 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) { case "dictionary" : - this.main_container.getChildren().add(new Text("dictionary")); - break; - case "exercises" : /* (1) Load the root_disp.fxml */ - FXMLLoader loader = new FXMLLoader(); + 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(); - } + try { + this.main_container.getChildren().add((AnchorPane) loader.load()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + break; + case "exercises" : + /* (1) Load the root_disp.fxml */ + loader = new FXMLLoader(); + + loader.setLocation(getClass().getResource("/fxml/exercise_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; case "translator" : this.root_layout.lookup("#submenu").setVisible(false); diff --git a/css/container.css b/css/container.css index 863736b..754b5be 100644 --- a/css/container.css +++ b/css/container.css @@ -13,4 +13,14 @@ -fx-pref-height: 26; -fx-pref-width: 759; -fx-margin: 20 0 20 0; +} + +#vocab > * > *{ + -fx-background-color: #ffffff; + -fx-border-width: 0 0 1 0; + -fx-border-color: #dddddd; +} + +#vocab{ + -fx-cursor: normal; } \ No newline at end of file diff --git a/css/menu.css b/css/menu.css index c6b193d..b4223bf 100644 --- a/css/menu.css +++ b/css/menu.css @@ -36,6 +36,10 @@ -fx-border-color: #eeeeee; } +.menu_item.active{ + -fx-background-color: #eeeeee; +} + #menu{ -fx-background-color: #ffffff; diff --git a/fxml/exercise_disp.fxml b/fxml/exercise_disp.fxml new file mode 100644 index 0000000..b5abe7d --- /dev/null +++ b/fxml/exercise_disp.fxml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + +