You have to write a code in JAVA ECLIPSE
Need help with this assignment?Get an original answer from a qualified tutor — from $10/page.
Get it written →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
Get a plagiarism-free answer to this question
Send us your instructions and we’ll match you with the best writer in your subject.
- 100% human-written, zero AI
- Turnitin report included
- Confidential — we never share your data
- Free revisions & refunds
