├── .classpath ├── .project ├── .settings ├── org.eclipse.jdt.core.prefs └── org.eclipse.m2e.core.prefs ├── Music ├── Song1.mpeg ├── song2.mpeg ├── song3.mpeg └── song4.mpeg ├── bin └── application │ ├── Main.class │ ├── Test.fxml │ ├── TestController.class │ └── application.css ├── build.fxbuild ├── pom.xml ├── src ├── application │ ├── Controller.java │ ├── Food.fxml │ ├── Login.fxml │ ├── Login.java │ ├── Logout.fxml │ ├── Main.fxml │ ├── Main.java │ ├── Menu.fxml │ ├── MusicController.java │ ├── MusicPlayer.fxml │ ├── Scene.java │ ├── Temp.fxml │ ├── Test.fxml │ ├── TestController.java │ ├── application.css │ ├── bulb.fxml │ ├── bulb1.png │ ├── bulb2.png │ ├── energy-drink.png │ ├── hamburger.png │ ├── pizza.png │ └── slider.java ├── icon.png └── module-info.java └── target └── classes ├── META-INF ├── MANIFEST.MF └── maven │ └── HelloJavafx │ └── HelloJavafx │ ├── pom.properties │ └── pom.xml ├── application ├── Controller.class ├── Food.fxml ├── Login.class ├── Login.fxml ├── Logout.fxml ├── Main.class ├── Main.fxml ├── Menu.fxml ├── MusicController$1.class ├── MusicController$2.class ├── MusicController.class ├── MusicPlayer.fxml ├── Temp.fxml ├── Test.fxml ├── TestController.class ├── application.css ├── bulb.fxml ├── bulb1.png ├── bulb2.png ├── energy-drink.png ├── hamburger.png ├── pizza.png ├── slider$1.class └── slider.class ├── icon.png └── module-info.class /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | HelloJavafx 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.xtext.ui.shared.xtextBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.m2e.core.maven2Nature 26 | org.eclipse.xtext.ui.shared.xtextNature 27 | org.eclipse.jdt.core.javanature 28 | 29 | 30 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=20 3 | org.eclipse.jdt.core.compiler.compliance=20 4 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 6 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 7 | org.eclipse.jdt.core.compiler.release=enabled 8 | org.eclipse.jdt.core.compiler.source=20 9 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /Music/Song1.mpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbdullahAssi/Java-Practice/7568055838ec39cfc48944bc4f9c8be9431fa351/Music/Song1.mpeg -------------------------------------------------------------------------------- /Music/song2.mpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbdullahAssi/Java-Practice/7568055838ec39cfc48944bc4f9c8be9431fa351/Music/song2.mpeg -------------------------------------------------------------------------------- /Music/song3.mpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbdullahAssi/Java-Practice/7568055838ec39cfc48944bc4f9c8be9431fa351/Music/song3.mpeg -------------------------------------------------------------------------------- /Music/song4.mpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbdullahAssi/Java-Practice/7568055838ec39cfc48944bc4f9c8be9431fa351/Music/song4.mpeg -------------------------------------------------------------------------------- /bin/application/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbdullahAssi/Java-Practice/7568055838ec39cfc48944bc4f9c8be9431fa351/bin/application/Main.class -------------------------------------------------------------------------------- /bin/application/Test.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bin/application/TestController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbdullahAssi/Java-Practice/7568055838ec39cfc48944bc4f9c8be9431fa351/bin/application/TestController.class -------------------------------------------------------------------------------- /bin/application/application.css: -------------------------------------------------------------------------------- 1 | /* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */ -------------------------------------------------------------------------------- /build.fxbuild: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | HelloJavafx 5 | HelloJavafx 6 | 0.0.1-SNAPSHOT 7 | 8 | src 9 | 10 | 11 | src 12 | 13 | **/*.java 14 | 15 | 16 | 17 | 18 | 19 | maven-compiler-plugin 20 | 3.8.1 21 | 22 | 20 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/application/Controller.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | 4 | import java.io.IOException; 5 | import javafx.event.ActionEvent; 6 | import javafx.fxml.FXML; 7 | import javafx.fxml.FXMLLoader; 8 | import javafx.scene.Node; 9 | import javafx.scene.Parent; 10 | import javafx.scene.Scene; 11 | import javafx.scene.control.Alert; 12 | import javafx.scene.control.Alert.AlertType; 13 | import javafx.scene.control.Button; 14 | import javafx.scene.control.ButtonType; 15 | import javafx.scene.control.CheckBox; 16 | import javafx.scene.control.Label; 17 | import javafx.scene.control.RadioButton; 18 | import javafx.scene.control.TextField; 19 | import javafx.scene.image.Image; 20 | import javafx.scene.image.ImageView; 21 | import javafx.scene.layout.AnchorPane; 22 | 23 | import javafx.scene.shape.Circle; 24 | import javafx.stage.Stage; 25 | 26 | 27 | 28 | 29 | public class Controller{ 30 | 31 | @FXML 32 | private Circle mycircle; 33 | private double x; 34 | private double y; 35 | @FXML 36 | TextField nameTextField; 37 | 38 | private Stage stage; 39 | private Scene scene; 40 | private Parent root; 41 | 42 | @FXML 43 | private Button logoutButton; 44 | @FXML AnchorPane sectionPane; 45 | 46 | @FXML 47 | private CheckBox myCheckButton; 48 | @FXML 49 | private Label myLabel; 50 | @FXML 51 | private ImageView myImageView; 52 | 53 | @FXML 54 | private ImageView Myimg; 55 | @FXML 56 | 57 | private RadioButton button1,button2,button3; 58 | 59 | @FXML 60 | private Label nameLabel; 61 | 62 | 63 | Image myImage1 = new Image(getClass().getResourceAsStream("bulb1.png")); 64 | Image myImage2 = new Image(getClass().getResourceAsStream("bulb2.png")); 65 | Image myImage3 = new Image(getClass().getResourceAsStream("pizza.png")); 66 | Image myImage5 = new Image(getClass().getResourceAsStream("energy-drink.png")); 67 | Image myImage4 = new Image(getClass().getResourceAsStream("hamburger.png")); 68 | 69 | 70 | public void getFood (ActionEvent event) { 71 | if(button1.isSelected()) { 72 | Myimg.setImage(myImage3); 73 | } 74 | else if(button2.isSelected()){ 75 | Myimg.setImage(myImage4); 76 | } 77 | else if(button3.isSelected()){ 78 | Myimg.setImage(myImage5); 79 | } 80 | } 81 | 82 | public void change (ActionEvent event) { 83 | if(myCheckButton.isSelected()) { 84 | System.out.println("ON"); 85 | myLabel.setText("ON"); 86 | myImageView.setImage(myImage1); 87 | } 88 | else { 89 | System.out.println("OFF"); 90 | myLabel.setText("OFF"); 91 | myImageView.setImage(myImage2); 92 | } 93 | } 94 | public void logout(ActionEvent event) { 95 | 96 | Alert alert = new Alert(AlertType.CONFIRMATION); 97 | alert.setTitle("Logout"); 98 | alert.setHeaderText("Your are About to Leave"); 99 | alert.setContentText("Do You want to Save Before Exiting"); 100 | 101 | if(alert.showAndWait().get() == ButtonType.OK) { 102 | stage = (Stage) sectionPane.getScene().getWindow(); 103 | System.out.println("Logged out"); 104 | stage.close(); 105 | } 106 | } 107 | 108 | public void Login(ActionEvent event) throws IOException { 109 | String username = nameTextField.getText(); 110 | FXMLLoader loader = new FXMLLoader(getClass().getResource("Test.fxml")); 111 | root = loader.load(); 112 | 113 | Controller loginC = loader.getController(); 114 | loginC.displayName(username); 115 | System.out.println("Logged In as" + username); 116 | } 117 | 118 | 119 | public void displayName(String username) { 120 | nameLabel.setText("Welcome: " + username); 121 | } 122 | public void switchToScene1(ActionEvent event) throws IOException { 123 | root = FXMLLoader.load(getClass().getResource("Test.fxml")); 124 | stage=(Stage) ((Node)event.getSource()).getScene().getWindow(); 125 | scene = new Scene(root); 126 | stage.setScene(scene); 127 | stage.show(); 128 | } 129 | public void switchToScene2(ActionEvent event) throws IOException { 130 | Parent root = FXMLLoader.load(getClass().getResource("Main.fxml")); 131 | stage=(Stage) ((Node)event.getSource()).getScene().getWindow(); 132 | scene = new Scene(root); 133 | stage.setScene(scene); 134 | stage.show(); 135 | 136 | } 137 | 138 | public void switchToScene3(ActionEvent event) throws IOException { 139 | root = FXMLLoader.load(getClass().getResource("Bulb.fxml")); 140 | stage=(Stage) ((Node)event.getSource()).getScene().getWindow(); 141 | scene = new Scene(root); 142 | stage.setScene(scene); 143 | stage.show(); 144 | } 145 | public void switchToScene4(ActionEvent event) throws IOException { 146 | root = FXMLLoader.load(getClass().getResource("Food.fxml")); 147 | stage=(Stage) ((Node)event.getSource()).getScene().getWindow(); 148 | scene = new Scene(root); 149 | stage.setScene(scene); 150 | stage.show(); 151 | } 152 | public void switchToScene5(ActionEvent event) throws IOException { 153 | root = FXMLLoader.load(getClass().getResource("Temp.fxml")); 154 | stage=(Stage) ((Node)event.getSource()).getScene().getWindow(); 155 | scene = new Scene(root); 156 | stage.setScene(scene); 157 | stage.show(); 158 | } 159 | public void switchToScene6(ActionEvent event) throws IOException { 160 | root = FXMLLoader.load(getClass().getResource("Menu.fxml")); 161 | stage=(Stage) ((Node)event.getSource()).getScene().getWindow(); 162 | scene = new Scene(root); 163 | stage.setScene(scene); 164 | stage.show(); 165 | 166 | } 167 | public void switchToScene7(ActionEvent event) throws IOException { 168 | root = FXMLLoader.load(getClass().getResource("MusicPlayer.fxml")); 169 | stage=(Stage) ((Node)event.getSource()).getScene().getWindow(); 170 | scene = new Scene(root); 171 | stage.setScene(scene); 172 | stage.show(); 173 | 174 | } 175 | 176 | 177 | public void up(ActionEvent e) { 178 | mycircle.setCenterY(y-=10); 179 | System.out.println("UP"); 180 | } 181 | public void down(ActionEvent e) { 182 | mycircle.setCenterY(y+=10); 183 | System.out.println("Down"); 184 | } 185 | public void left(ActionEvent e) { 186 | mycircle.setCenterX(x-=10); 187 | System.out.println("Left"); 188 | } 189 | public void right(ActionEvent e) { 190 | mycircle.setCenterX(x+=10); 191 | System.out.println("Right"); 192 | } 193 | 194 | 195 | 196 | 197 | } 198 | 199 | -------------------------------------------------------------------------------- /src/application/Food.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 26 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/application/Main.java: -------------------------------------------------------------------------------- 1 | package application; 2 | 3 | import javafx.application.Application; 4 | import javafx.event.ActionEvent; 5 | import javafx.fxml.FXMLLoader; 6 | import javafx.scene.Parent; 7 | import javafx.scene.Scene; 8 | import javafx.scene.control.Alert; 9 | import javafx.scene.control.ButtonType; 10 | import javafx.scene.control.Alert.AlertType; 11 | import javafx.stage.Stage; 12 | 13 | public class Main extends Application { 14 | 15 | public static void main(String[] args) { 16 | launch(args); 17 | } 18 | 19 | @Override 20 | public void start(Stage primaryStage) throws Exception { 21 | Parent root = FXMLLoader.load(getClass().getResource("Login.fxml")); 22 | Scene scene = new Scene(root); 23 | // scene.getStylesheets().add(getClass().getResource("Application.css").toExternalForm()); 24 | primaryStage.setScene(scene); 25 | primaryStage.show(); 26 | 27 | primaryStage.setOnCloseRequest(event -> { 28 | event.consume(); 29 | logout(primaryStage); 30 | }); 31 | } 32 | 33 | public void logout(Stage primaryStage) { 34 | 35 | Alert alert = new Alert(AlertType.CONFIRMATION); 36 | alert.setTitle("Exit"); 37 | alert.setHeaderText("Your are About to Exit"); 38 | alert.setContentText("Do You want to Save Before Exiting"); 39 | 40 | if(alert.showAndWait().get() == ButtonType.OK) { 41 | // stage = (Stage) sectionPane.getScene().getWindow(); 42 | System.out.println("Logged out"); 43 | primaryStage.close(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/application/Menu.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 19 | 24 | 29 | 34 | 39 | 40 | 41 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/application/Scene.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbdullahAssi/Java-Practice/7568055838ec39cfc48944bc4f9c8be9431fa351/src/application/Scene.java -------------------------------------------------------------------------------- /src/application/Temp.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /target/classes/application/Menu.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 19 | 24 | 29 | 34 | 39 | 40 | 41 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /target/classes/application/Temp.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 |