Java Programming – FlowPane Write a program that meets the following requirement
ID: 3681763 • Letter: J
Question
Java Programming
– FlowPane Write a program that meets the following requirements.
• Create two stages in a program
• Create a pane using FlowPane in each stage
• Add three buttons to each pane Directions
• Create a class named FlowPaneDemo extends Application
• Create user interface using FlowPane
• Add the instances of 3 Buttons to pane1 created by FlowPane and other 3 instances of Buttons using FlowPane to pane2
• Create scene1 for pane1 with a specific size and scene2 for pane2 with a different size
• Set different titles to two stages and display two stages
• Provide appropriate Java comments
Explanation / Answer
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author RAM
*/
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.layout.FlowPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class FlowPaneDemo extends Application{
@Override
public void start(Stage stage) {
stage.setTitle("HTML");
stage.setWidth(500);
stage.setHeight(500);
Scene scene = new Scene(new Group());
//Intiliaze FlowPane
FlowPane flow = new FlowPane();
flow.setVgap(8);
flow.setHgap(4);
flow.setPrefWrapLength(300); // preferred width = 300
for (int i = 0; i < 10; i++) {
// Creating new Buttons
flow.getChildren().add(new Button("Button 1"));
flow.getChildren().add(new Button("Button 2"));
flow.getChildren().add(new Button("Button 3"));
}
scene.setRoot(flow);
//creating user interface
FlowPane pane = new FlowPane(10, 10);
pane.setBorder(new Border(new BorderStroke(Color.BLACK,
BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
//each stage
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.