Question

Write a JavaFX program to display 5 labels and 3 buttons. You can use any kind...

Write a JavaFX program to display 5 labels and 3 buttons. You can use any kind of Pane you like to use. Display 3 red circles and 2 blue rectangles (pick your own size). Use the Image and ImageView classes (explained in section 14.9 of your textbook) to show 2 images of your choice. Include your first and last name somewhere on the frame, label, button, etc. We won’t discuss handing events where one would be able to click buttons and expect results.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.*;
import javafx.scene.control.*;
import javafx.stage.Stage;


public class JavaFXExample extends Application{
public static void main(String[] args) throws Exception { launch(args); }
    @Override
    public void start(final Stage stage) throws Exception {
    //here in the Strings you can add your name
        Label l1 = new Label("   DJ Style 1   ");
        Label l2 = new Label("   DJ Style 2   ");
        Label l3 = new Label("   DJ Style 3   ");
        Label l4 = new Label("   DJ Style 4   ");
        Label l5 = new Label("   DJ Style 5   ");

        FlowPane lPane = new FlowPane();
        lPane.getChildren().addAll(l1,l2,l3,l4,l5);

        Button b1 = new Button(" Click 1 ");
        Button b2 = new Button(" Click 2 ");
        Button b3 = new Button(" Click 3 ");
        FlowPane bPane = new FlowPane();
        bPane.getChildren().addAll(b1,b2,b3);

        Circle c1 = new Circle(40);
        Circle c2 = new Circle(50);
        Circle c3 = new Circle(30);
        c1.setFill(Color.RED);
        c2.setFill(Color.RED);
        c3.setFill(Color.RED);
        FlowPane cPane = new FlowPane();
        cPane.getChildren().addAll(c1,c2,c3);

        Rectangle r1 = new Rectangle(200,200,Color.BLUE);
        Rectangle r2 = new Rectangle(300,200,Color.BLUE);

        BorderPane mainPane = new BorderPane();
        mainPane.setTop(lPane);
        mainPane.setBottom(bPane);
        mainPane.setRight(r1);
        mainPane.setLeft(r2);
        mainPane.setCenter(cPane);

        Scene scene = new Scene(mainPane,700,320);
        stage.setTitle("JavaFX Example");
        stage.setScene(scene);
        stage.show();
    }
}

Add a comment
Know the answer?
Add Answer to:
Write a JavaFX program to display 5 labels and 3 buttons. You can use any kind...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please answer correctly and follow the code structure given [JavaFX/ Exception handing and text I/O] 1....

    please answer correctly and follow the code structure given [JavaFX/ Exception handing and text I/O] 1. Write a program for the following. NOTE that some of these steps are not dependent on each other. Using methods is mandatory. Make sure to use methods where it makes sense. a. Ask the user for a series of integers entered from the keyboard. Use a sentinel value such as 999 to end the input process. If the entered values are not integers, throw...

  • you need to use javafx for following problem these instructions is for JavaFX program so you...

    you need to use javafx for following problem these instructions is for JavaFX program so you need to follow the instructions and according to images you have design the GUI Write a program to design the following interface and use event handling and File 10 to perform the given operation. Make sure you have a background image and different color for labels and buttons for this interface. Input Information Course Quiz Grade Assignment Grade Fal Grade Submit View Grade Info...

  • Answer questions 1-20 about creating GUI applications with JavaFX 1. A tree-like data structure that contains...

    Answer questions 1-20 about creating GUI applications with JavaFX 1. A tree-like data structure that contains the components of a JavaFX GUI is called a: a. directory tree b. node tree c.node graph d. scene graph 2. A node in a scene graph that contains other nodes is called a: a. root node b. branch node c. leaf node d. terminal node 3. A node in a scene graph that has no children is called a: a. root node b....

  • JAVAFX ONLY PROGRAM!!!!! SORTING WITH NESTED CLASSES AND LAMBDA EXPRESSIONS. DIRECTIONS ARE BELOW: DIRECTIONS: The main...

    JAVAFX ONLY PROGRAM!!!!! SORTING WITH NESTED CLASSES AND LAMBDA EXPRESSIONS. DIRECTIONS ARE BELOW: DIRECTIONS: The main point of the exercise is to demonstrate your ability to use various types of nested classes. Of course, sorting is important as well, but you don’t really need to do much more than create the class that does the comparison. In general, I like giving you some latitude in how you design and implement your projects. However, for this assignment, each piece is very...

  • Java Painter Class This is the class that will contain main. Main will create a new...

    Java Painter Class This is the class that will contain main. Main will create a new Painter object - and this is the only thing it will do. Most of the work is done in Painter’s constructor. The Painter class should extend JFrame in its constructor.  Recall that you will want to set its size and the default close operation. You will also want to create an overall holder JPanel to add the various components to. It is this JPanel that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT