{"id":20444923,"url":"https://github.com/celeroncoder/javafx","last_synced_at":"2026-04-20T14:32:18.608Z","repository":{"id":39747872,"uuid":"368421961","full_name":"celeroncoder/JavaFX","owner":"celeroncoder","description":"GUI components with JavaFX (~my learning repo)","archived":false,"fork":false,"pushed_at":"2022-05-26T13:59:02.000Z","size":2197,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-05T08:36:47.493Z","etag":null,"topics":["components","gui","javafx"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/celeroncoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-18T06:19:37.000Z","updated_at":"2022-05-26T14:00:00.000Z","dependencies_parsed_at":"2022-09-20T10:24:24.153Z","dependency_job_id":null,"html_url":"https://github.com/celeroncoder/JavaFX","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/celeroncoder/JavaFX","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celeroncoder%2FJavaFX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celeroncoder%2FJavaFX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celeroncoder%2FJavaFX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celeroncoder%2FJavaFX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/celeroncoder","download_url":"https://codeload.github.com/celeroncoder/JavaFX/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/celeroncoder%2FJavaFX/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32050899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T11:35:06.609Z","status":"ssl_error","status_checked_at":"2026-04-20T11:34:48.899Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["components","gui","javafx"],"created_at":"2024-11-15T10:10:07.244Z","updated_at":"2026-04-20T14:32:18.578Z","avatar_url":"https://github.com/celeroncoder.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JavaFX\n`A repo including all the core concepts of JavaFX`\n\n## What is JavaFX?\nJavaFX is a GUI(Graphical User Interface) Library in Java similar to core GUI Library Swing.\n\n## Topics Covered\n- **Scene**\n- **Scene Builder**\n- **Switching Scenes** within a Stage\n\t- typecasting to switch scenes\n\t\t```java\n\t\tstage = (Stage) ((Node) event.getSource()).getScene().getWindow();\n\t\t```\n- Using CSS Styling with Scenes\n\t- adding css stylesheet to the Scene\n\t\t```java\n\t\tScene.getStylesheets().add(getClass().getResource(\"Main.css\").toExternalForm());\n\t\t```\n\t- reusing stylesheet to use in different scenes\n\t\t```java\n\t\tString css = this.getClass().getResource(\"Main.css\").toExternalForm();\n\t\tScene.getStylesheets().add(css);\n\t\t```\n- Communicating b/w different controllers\n\t- Using FXML elements within controllers\n\t\t```java\n\t\t@FXML\n\t\tTextField username;\n\n\t\tprivate Stage stage;\n\t\tprivate Scene Scene;\n\t\tprivate Parent root;\n\t\t```\n\t- Reusing FXMLLoader Instance\n\t\t```java\n\t\tFXMLLoader loader = new FXMLLoader(Objects.requireNonNull(getClass().getResource(\"Scene2.fxml\")));\n\t\troot = loader.load();\n\t\t```\n\t- Creating Instances of Other Controllers of the package\n\t\t```java\n\t\tScene2_Controller scene2_controller = loader.getController();\n\t\t```\n- **ImageView** Node\n\t- How to set up ImageView Node in SceneBuilder\n\t- Switch Images of the ImageView Node\n\t```java\n\tpublic void toggleImage() {\n\t\tif (imageContainer.getImage() == image1) {\n\t\t\timageContainer.setImage(image2);\n\t\t} else {\n\t\t\timageContainer.setImage(image1);\n\t\t}\n\t}\n\t```\n- **TextField** Node\n- **CheckBoxes**\n- **RadioButtons**\n\t- Make sure to put all the radio-buttons in the same toggle group variable in the fxml file\n\t\t```fxml\n\t\t\u003ctoggleGroup\u003e\n            \u003cToggleGroup fx:id=\"food\" /\u003e\n         \u003c/toggleGroup\u003e\n\t\t```\n- **Color Picker**\n\t- How to set the background of the AnchorPane(`javafx.Scene.layout.AnchorPane`) with Color(`javafx.Scene.paint.Color`)\n\t\t```java\n\t\tAnchorPane background;\n\t\tColor color = Color.RED;\n\t\tbackground.setBackground(new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY)));\n\t\t// or \n\t\tbackground.setBackground(new Background(new BackgroundFill(color, null, null)));\n\t\t```\n- **Choice Boxes**\n\t- How to set the items of a choicebox and set the action event method\n\t\t- To add anything to the nodes after the root node has been declared with the FXML File we can use the intialize method as \n\t\t\t```java\n\t\t\tpublic class Controller implements Initializable {\n\t\t\t\t@Override\n\t\t\t\tpublic void initialize(URL arg0, ResourceBundle arg1) {\n\t\t\t\t\t// do something\n\t\t\t\t}\n\t\t\t}\n\t\t\t```\n\t\t- Adding items to the choicebox\n\t\t\t```java\n\t\t\t\tprivate String[] food = {\n\t\t\t\t\t\"sushi\",\n\t\t\t\t\t\"burger\",\n\t\t\t\t\t\"ramen\"\n\t\t\t\t};\n\t\t\t\t\n\t\t\t\t@Override\n\t\t\t\tpublic void initialize(URL arg0, ResourceBundle arg1) {\n\t\t\t\t\tchoiceBox.getItems().addAll(food); // addAll takes a collection\n\t\t\t\t}\n\t\t\t```\n\t\t- setting the onAction event of choicebox or any node\n\t\t\t```java\n\t\t\t@FXML\n\t\t\tprivate ChoiceBox\u003cString\u003e choiceBox;\n\t\t\t@Override\n\t\t\tpublic void initialize(URL arg0, ResourceBundle arg1) {\n\t\t\t\tchoiceBox.setOnAction(this::showFood); // this:: is a method reference operator\n\t\t\t}\n\t\t\t```\n- **Slider**\n\t- adding the ChangeListner to the slider using initialize method in the Controller class\n\t\t```java\n\t\tclass Controller implements Initializable {\n\t\t\t@Override\n\t\t\tpublic void initialize(URL arg0, ResourceBundle arg1) {\n\t\t\t\ttemperatureSlider.valueProperty().addListener(new ChangeListener\u003cNumber\u003e() { // Using Number Generic Type since temperature variable is an integer\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void changed(ObservableValue\u003c? extends Number\u003e observableValue, Number number, Number t1) {\n\t\t\t\t\t\ttemperature = (int) temperatureSlider.getValue();\n\t\t\t\t\t\ttemp.setText(Integer.toString(temperature)+ \"C\");\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\t```\n- **Spinner**\n\t- adding values to the Spinner with _SpinnerValueFactory_\n\t\t```java\n\t\tSpinnerValueFactory\u003cInteger\u003e valueFactory = new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 10);\n\t\t// default value\n\t\tvalueFactory.setValue(1);\n\t\tfoodSpinner.setValueFactory(valueFactory);\n\t\tcurrentValue = foodSpinner.getValue();\n\t\tspinnerLabel.setText(Integer.toString(currentValue));\n\t\t```\n\t- adding eventListner on value change\n\t\t```java\n\t\t\tfoodSpinner.valueProperty().addListener(new ChangeListener\u003cInteger\u003e() {\n\t\t\t@Override\n\t\t\tpublic void changed(ObservableValue\u003c? extends Integer\u003e observableValue, Integer integer, Integer t1) {\n\t\t\t\tcurrentValue = foodSpinner.getValue();\n\t\t\t\tspinnerLabel.setText(Integer.toString(currentValue));\n\t\t\t}\n\t\t```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceleroncoder%2Fjavafx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceleroncoder%2Fjavafx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceleroncoder%2Fjavafx/lists"}