Question
JavaFX FlowPane setup. Trying to set up a window that has two pictures. I am just looking for tips on how to setup my stage
JavaFX FlowPane setup. Trying to set up a window that has two pictures. I am just looking for tips on how to setup my stage and scene in the first section. Over all I want (two picture spots) within the scene and a (pushbutton), along with a (listener) at bottom. I cannot add to my imports at top, I must follow design. Any tips on how to set this up would be appreciated.
Thank-you
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.FlowPane;
//**********************************************************************
// 3-18-17
//
//
//**********************************************************************
public class GUIDriver extends Application
{
private Text sumText;
private PigDice p;
private ImageView die1View, die2View;
//------------------------------------------------------------------
// Demonstrates Images of rolled dice
//------------------------------------------------------------------
public void start(Stage primaryStage)
{
Image img = new Image("Die1Image.jpg, Die2Image.jpg.");
ImageView imgView = new ImageView(img);
FlowPane pane = new FlowPane(imgView);
pane.setStyle("-fx-background-color: cornsilk");
Scene scene = new Scene(pane, 500, 400);
primaryStage.setTitle("Image Display");
primaryStage.setScene(scene);
primaryStage.show();
}
//--------------------------------------------------------------------
//
//--------------------------------------------------------------------
public void processButtonPress(ActionEvent event)
{
pigDice p = new pigDice();
p.roll();
sumText.setText("sum is: " + p.toString());
Button roll = new Button("roll dice!");
roll.setOnAction(this::processButtonPress);
//-------------------------------------------------------------------
// optional depending on IDE
//-------------------------------------------------------------------
public static void main(String[] args)
{
launch(args);
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started