Question

Create a GUI or JavaFX application with two buttons and two labels. Add an Image Icon of your choice to the first button...

Create a GUI or JavaFX application with two buttons and two labels. Add an Image Icon of your choice to the first button and the first label.

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

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.layout.GridPane;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
public class GUISample extends Application
{
public void start(Stage stage)
{
//create gridpane for adding buttons and labels
GridPane rootPane=new GridPane();
Scene scene=new Scene(rootPane,400,400); //scene used to represent physical contents of application
Image image1=new Image(getClass().getResourceAsStream("buttonicon.jpg"));
Image image2=new Image(getClass().getResourceAsStream("labelicon.jpg"));
//create two buttons
Button button1=new Button("Button1");
Button button2=new Button("Button2");
//create 2 labels
Label label1=new Label("label1");
Label label2=new Label("label2");
//set icon for Button & label
button1.setGraphic(new ImageView(image1));
label1.setGraphic(new ImageView(image2));
//add to pane
rootPane.addRow(0,label1);
rootPane.addRow(1,button1);
rootPane.addRow(2,label2);
rootPane.addRow(3,button2);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args)
{
launch(args);
}
}

Add a comment
Know the answer?
Add Answer to:
Create a GUI or JavaFX application with two buttons and two labels. Add an Image Icon of your choice to the first button...
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
  • JAVASCRIPT Write a GUI application that has three labels, two text fields, and two buttons (with...

    JAVASCRIPT Write a GUI application that has three labels, two text fields, and two buttons (with the titles Name and Age). When the program starts the user will enter his/her first name in the first text field and his age in the second text field. When the user clicks the Name button, the first name entered by the user will be displayed as a separate label with the words "CSC210 student at the back of it. When the user clicks...

  • For this question you will need to complete the methods to create a JavaFX GUI application...

    For this question you will need to complete the methods to create a JavaFX GUI application that implements two String analysis algorithms. Each algorithm is activated when its associated button is pressed. They both take their input from the text typed by the user in a TextField and they both display their output via a Text component at the bottom of the GUI, which is initialized to “Choose a string methods as indicated in the partially completed class shown after...

  • Java (8th Edition) Chapter 6, Problem 12PGP Looking for a solution to this question. Edit: I...

    Java (8th Edition) Chapter 6, Problem 12PGP Looking for a solution to this question. Edit: I was missing the question.. Create a GUI or JavaFX application that displays a button with the text "Button 1". Underneath the button add a label with the text "label 1". Repeat with and additional "Button 2" and "Label 2". Add an image icon of your choice to the first button and the first label.

  • Using JavaFX create a Roll application that implements the GUI shown When the user clicks the Rol...

    Using JavaFX create a Roll application that implements the GUI shown When the user clicks the Roll button, the program must roll the dice, change the figures randomly, calculate the sum of the dice and show it in a label

  • 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...

  • JavaFX Programming Develop a temperature converter GUI JavaFX application that consists of two labels and two...

    JavaFX Programming Develop a temperature converter GUI JavaFX application that consists of two labels and two text fields. Typing a temperature into the Celsius field and then pressing the "Enter" key causes the equivalent Fahrenheit temperature to appear in the Fahrenheit field and vice versa. Temperature Converter Celsius 100 Fahrenheit 212.0 Typing a non-numeric value into either field causes the following error dialog to appear: Message Error, input must be numerical OK Formulas are simple: Celsius to Fahrenheit F =...

  • I. User Interface Create a JavaFX application with a graphical user interface (GUI) based on the...

    I. User Interface Create a JavaFX application with a graphical user interface (GUI) based on the attached “GUI Mock-Up”. Write code to display each of the following screens in the GUI: A. A main screen, showing the following controls: • buttons for “Add”, “Modify”, “Delete”, “Search” for parts and products, and “Exit” • lists for parts and products • text boxes for searching for parts and products • title labels for parts, products, and the application title B. An add...

  • Create a Web application that stores name and ID into an array. The GUI should asked...

    Create a Web application that stores name and ID into an array. The GUI should asked the user to enter a last name, a first name, and an ID. Make it sure that the inputs are valid: names contain only letters and ID 6-digit number. Add to buttons to the interface: Add button to insert the inputs into an array, and a Show button to list all the inputs.

  • Develop a temperature converter GUI JavaFX application that consists of two labels and two text fields....

    Develop a temperature converter GUI JavaFX application that consists of two labels and two text fields. Typing a temperature into the Celsius field and then pressing the "Enter" key causes the equivalent Fahrenheit temperature to appear in the Fahrenheit field and vice versa. Typing a non-numeric value into either field causes the following error dialog to appear: Formulas are simple:Celsius to Fahrenheit° F = 9/5 ( ° C) + 32Fahrenheit to Celsius° C = 5/9 (° F - 32). O®...

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