You have to write a code in JAVA ECLIPSE
OOPDA Lab 12-A JavaFX GUI #1 1. Using JavaFX classes, we extend Application and begin with a “blank” stage… • Easiest: create a Java project and add code from MyFirstGUI.java as initial class. 1. Make an empty scene… 2. Make a Label, Button 3. Make an HBox and put controls into it 4. make it do something… Set the title of the PRIMARY Stage as “OOPDA Lab 12A” [can do this after you set the scene] ➔RUN Test your initial code: should bring up a “blank” window. (Take a screenshot) Example Code for some simple scene 2. Create two GUI Controls. Add to start(): a) Create a Label “Press the Button” b) Create a Button “Press Me” Note: you will need to add import statements for Button and Label… ➔BE SURE to import the JavaFX versions, NOT the AWT versions!!! 3. Next, use HBox as a Layout Container to position elements in the scene c) Put the Button and the Label into an HBox (Horizontal – so button will appear to left of the label) Note: syntax for multiple inserts into a VBox, as an example: VBox vbox = new VBox(10, label1, label2); //allows 10 pixels as space between elements) ➔RUN Test your code: should show button and label. (Take a screenshot) ➔Now, make Button do something… 4. Move controls (e.g., myButton, myLabel ) so they are declared as instance variables in the Application class. TEST again! 5. Let’s make the button change the Label’s text to “Thanks for clicking” . • We want to execute this: messageLabel.setText(“Thanks for clicking”); • Register an eventHandler using a lambda: o myButton.setOnAction(click-> ); //add rest of the lambda! • Test! Lab 12-A JavaFX Lab #1 p. 1 11/5/2022 2:27 PM 6. Enhancement: Add a statement(s) to the lambda [use curly braces!] to also change background color of the label (or the button, or both). Example: label99.setStyle(“-fx-background-color: orange”); 7. Challenge (if time): detect the “state” of the button (e.g., the color or the text), and toggle so the initial state changes to a second state, then back to initial state etc. – every time button is pressed. [Could further improvise!] Hint: We must detect the state of the button and/or the label. Simple approach: get the text of the label… Lab12-A deliverables • Zip of project + WORD doc with some screen shots of test run(s) during development. Lab 12-A JavaFX Lab #1 p. 2 11/5/2022 2:27 PM
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.