I am just a beginner in javafx.I was just seeing some examples in ensemble.jar and has a doubt in the following program.Here in this there are 2 methods start
and init
both of which accepts arguments of type Stage
. init()
is called from start()
.My doubt is stage decoration(adding group,progressindicator,gridpane) is done in start method.So primaryStage.show()
will display the decorated stage but here if I write primaryStage1.show()
in the start()
then also decorated stage is also displaying.I want to know how
package fx;
/**
* Copyright (c) 2008, 2012 Oracle and/or its affiliates.
* All rights reserved. Use is subject to license terms.
*/
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.GridPane;
/**
* A sample that demonstrates the Progress Indicator control in various modes.
*
* @see javafx.scene.control.ProgressIndicator
* @related controls/ProgressBar
*/
public class ProgressIndicatorSample extends Application {
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 400,400));
GridPane g = new GridPane();
ProgressIndicator p1 = new ProgressIndicator();
p1.setPrefSize(50, 50);
ProgressIndicator p2 = new ProgressIndicator();
p2.setPrefSize(50, 50);
p2.setProgress(0.25F);
ProgressIndicator p3 = new ProgressIndicator();
p3.setPrefSize(50, 50);
p3.setProgress(0.5F);
ProgressIndicator p4 = new ProgressIndicator();
p4.setPrefSize(50, 50);
p4.setProgress(1.0F);
g.add(p1, 1, 0);
g.add(p2, 0, 1);
g.add(p3, 1, 1);
g.add(p4, 2, 1);
char x[]={'a','m'};
x.toString();
System.out.println(x);
g.setHgap(40);
g.setVgap(40);
root.getChildren().add(g);
}
public double getSampleWidth() { return 400; }
public double getSampleHeight() { return 400; }
@Override public void start(Stage primaryStage1) throws Exception {
init(primaryStage1);
primaryStage1.show();
}
public static void main(String[] args) { launch(args); }
}