Java Code Examples for javafx.stage.Stage#show()

The following examples show how to use javafx.stage.Stage#show() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReceptionistController.java    From HealthPlus with Apache License 2.0 8 votes vote down vote up
@FXML
public void showAppointmentSuccessIndicator(String patientId, String consult, String appDate, String appId)
{
    Stage stage= new Stage();
    AppointmentSuccessController success = new AppointmentSuccessController();
    
    success.fillAppointmentData(patientId,consult,appDate,appId);
    
    Scene scene = new Scene(success);
    stage.setScene(scene);
    
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //set Stage boundaries to visible bounds of the main screen
    stage.setX(primaryScreenBounds.getMinX());
    stage.setY(primaryScreenBounds.getMinY());
    stage.setWidth(primaryScreenBounds.getWidth());
    stage.setHeight(primaryScreenBounds.getHeight());
    
    stage.initStyle(StageStyle.UNDECORATED);
    scene.setFill(null);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.show();
}
 
Example 2
Source File: IndexChart - MainApp.java    From Java-for-Data-Science with MIT License 6 votes vote down vote up
public void simpleIndexChart(Stage stage) {
    stage.setTitle("Index Chart");
    final LineChart<String, Number> lineChart
            = new LineChart<>(xAxis, yAxis);
    lineChart.setTitle("Belgium Population");
    yAxis.setLabel("Population");

    series.setName("Population");
    addDataItem(series, "1950", 8639369);
    addDataItem(series, "1960", 9118700);
    addDataItem(series, "1970", 9637800);
    addDataItem(series, "1980", 9846800);
    addDataItem(series, "1990", 9969310);
    addDataItem(series, "2000", 10263618);

    Scene scene = new Scene(lineChart, 800, 600);
    lineChart.getData().add(series);
    stage.setScene(scene);
    stage.show();
}
 
Example 3
Source File: WebViewDemo.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) {

    StackPane root = new StackPane();
    WebView x = new WebView();
    WebEngine ex = x.getEngine();
    ex.load("https://github.com/travis-ci/travis-ci");

    root.getChildren().add(x);
    java.net.CookieHandler.setDefault(null);
    Scene scene = new Scene(root, 1024, 768);

    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 4
Source File: PolygonLayoutBoundsBug.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
	final Polygon p = new Polygon(10, 30, 20, 20, 20, 40);
	p.setFill(Color.RED);
	p.setStroke(Color.BLACK);

	final Rectangle r = new Rectangle();
	r.setFill(new Color(0, 0, 1, 0.5));
	r.setX(p.getLayoutBounds().getMinX());
	r.setY(p.getLayoutBounds().getMinY());
	r.setWidth(p.getLayoutBounds().getWidth());
	r.setHeight(p.getLayoutBounds().getHeight());

	Group g = new Group(r, p);
	g.getTransforms().add(new Scale(10, 10));
	Scene scene = new Scene(g, 500, 500);
	primaryStage.setScene(scene);
	primaryStage.sizeToScene();
	primaryStage.show();
}
 
Example 5
Source File: FXSandbox.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    for (int i=0; i<STAR_COUNT; i++) {
        nodes[i] = new Rectangle(1, 1, Color.WHITE);
        angles[i] = 2.0 * Math.PI * random.nextDouble();
        start[i] = random.nextInt(2000000000);
    }
    final Scene scene = new Scene(new Group(nodes), 800, 600, Color.BLACK);
    primaryStage.setScene(scene);
    primaryStage.show();
    
    new AnimationTimer() {
        @Override
        public void handle(long now) {
            final double width = 0.5 * primaryStage.getWidth();
            final double height = 0.5 * primaryStage.getHeight();
            final double radius = Math.sqrt(2) * Math.max(width, height);
            for (int i=0; i<STAR_COUNT; i++) {
                final Node node = nodes[i];
                final double angle = angles[i];
                final long t = (now - start[i]) % 2000000000;
                final double d = t * radius / 2000000000.0;
                node.setTranslateX(Math.cos(angle) * d + width);
                node.setTranslateY(Math.sin(angle) * d + height);
            }
        }
    }.start();
}
 
Example 6
Source File: MainController.java    From MusicPlayer with MIT License 5 votes vote down vote up
private void createVolumePopup() {
	try {
		
		Stage stage = MusicPlayer.getStage();
    	FXMLLoader loader = new FXMLLoader(this.getClass().getResource(Resources.FXML + "VolumePopup.fxml"));
    	HBox view = loader.load();
    	volumePopupController = loader.getController();
    	Stage popup = new Stage();
    	popup.setScene(new Scene(view));
    	popup.initStyle(StageStyle.UNDECORATED);
    	popup.initOwner(stage);
    	popup.setX(stage.getWidth() - 270);
    	popup.setY(stage.getHeight() - 120);
    	popup.focusedProperty().addListener((x, wasFocused, isFocused) -> {
    		if (wasFocused && !isFocused) {
    			volumeHideAnimation.play();
    		}
    	});
    	volumeHideAnimation.setOnFinished(x -> popup.hide());
    	
    	popup.show();
    	popup.hide();
    	volumePopup = popup;
    	
	} catch (Exception ex) {
		
		ex.printStackTrace();
	}
}
 
Example 7
Source File: StretchRendererSample.java    From arcgis-runtime-samples-java with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws IOException {
  // set up the scene
  FXMLLoader loader = new FXMLLoader(getClass().getResource("/stretch_renderer/main.fxml"));
  Parent root = loader.load();
  controller = loader.getController();
  Scene scene = new Scene(root);

  // set up the stage
  stage.setTitle("Stretch Renderer Sample");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(scene);
  stage.show();
}
 
Example 8
Source File: NoiseApp.java    From FXTutorials with MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    Scene scene = new Scene(createContent());
    primaryStage.setTitle("Noise App");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 9
Source File: WebViewJavaScriptToJavaDemo.java    From oim-fx with MIT License 5 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
	primaryStage.setTitle("What World");

	WebView webView = new WebView();
	WebPage webPage = null;
	WebEngine webEngine = webView.getEngine();

	webEngine.getLoadWorker().stateProperty().addListener((ObservableValue<? extends State> ov, State oldState, State newState) -> {
		System.out.println("loadWorker");
		if (newState == State.SUCCEEDED) {
			JSObject window = (JSObject) webEngine.executeScript("window");
			window.setMember("app", app);
			System.out.println("app");
		}
	});

	webPage = Accessor.getPageFor(webEngine);
	webPage.setJavaScriptEnabled(true);
	webPage.setEditable(false);
	webPage.setContextMenuEnabled(false);
	webView.setFocusTraversable(true);
	webView.getEngine().load(WebViewJavaScriptToJavaDemo.class.getResource("ScriptToJava.html").toExternalForm());

	Group root = new Group();
	Scene scene = new Scene(root, 1000, 550, Color.LIGHTBLUE);

	root.getChildren().add(webView);
	primaryStage.setScene(scene);
	primaryStage.show();
}
 
Example 10
Source File: Main.java    From FXTutorials with MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    Scene scene = new Scene(createContent());
    primaryStage.setTitle("Tutorial");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 11
Source File: FuelGauge.java    From medusademo with Apache License 2.0 5 votes vote down vote up
@Override public void start(Stage stage) {
    Scene scene = new Scene(pane);
    scene.getStylesheets().add(FuelGauge.class.getResource("fuel-gauge.css").toExternalForm());

    stage.setTitle("Medusa");
    stage.setScene(scene);
    stage.show();

    // Calculate number of nodes
    calcNoOfNodes(gauge);
    System.out.println(noOfNodes + " Nodes in SceneGraph");
}
 
Example 12
Source File: ButtonDemo.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("/fxui/fxml/buttondemo.fxml"));
    Scene scene = new Scene(root);
    scene.getStylesheets().add("/css/buttondemo.css");
    stage.setScene(scene);
    stage.setResizable(false);
    stage.setTitle("Button of choice - DEMO");
    stage.show();
}
 
Example 13
Source File: FXMLMain.java    From javafx-calendar with MIT License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("fullCalendar.fxml"));
    primaryStage.setTitle("Full Calendar FXML Example");
    primaryStage.setScene(new Scene(loader.load()));
    // Get the controller and add the calendar view to it
    Controller controller = loader.getController();
    controller.calendarPane.getChildren().add(new FullCalendarView(YearMonth.now()).getView());
    primaryStage.show();
}
 
Example 14
Source File: SliderGlitchDemo.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("nls")
@Override
public void start(final Stage stage)
{
    Slider slider = new Slider();
    slider.setOrientation(Orientation.VERTICAL);
    slider.setLayoutX(110);
    slider.setPrefHeight(200);
    slider.setValue(Double.NaN);

    Rectangle rect1 = createRect(10);
    rect1.setStyle("-fx-stroke-width: 1; -fx-stroke-dash-array: 5.0, 5.0; -fx-stroke: blue; -fx-fill: rgb(0, 0, 255, 0.05);");

    Rectangle rect2 = createRect(30);
    rect2.setStyle("-fx-stroke-width: 1; -fx-stroke: blue; -fx-fill: rgb(0, 0, 255, 0.05);");

    final Pane pane = new Pane(slider, rect1, rect2);
    pane.setPadding(new Insets(5));

    final Label label = new Label("Drag the bottom right corner of each rectangle across the slider. When the slider value is NaN,\n"
            + "the dashed rectangle freezes the program; the solid-bordered one disappears and reappears.\n"
            + "When it is finite, the rectangles behave as expected.");
    
    Button button = new Button("Toggle NaN/finite value.");
    button.setOnAction(e->
    {
        slider.setValue(Double.isFinite(slider.getValue()) ? Double.NaN : 50);
    });

    final VBox root = new VBox(pane, label, button);
    final Scene scene = new Scene(root, 800, 700);

    stage.setScene(scene);
    stage.setTitle("Slider Glitch Demo");

    stage.show();
}
 
Example 15
Source File: Main.java    From quantumjava with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    Function<Double, Double> classic = b -> Math.exp(Math.pow(64./9.*b* Math.log(b)*Math.log(b), 1./3));
    Function<Double, Double> shor = b-> Math.pow(b,3.);
    List<Function<Double,Double>> functions = Arrays.asList(classic, shor);
    Chart chart = plotFunction(functions, 0.000001, 20);
      Scene scene = new Scene(chart, 640, 480);
        stage.setScene(scene);
        stage.show();

}
 
Example 16
Source File: MainApp.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
	
	//
	// Check for plugins
	//
	String pathToPlugin = 
			"/home/carl/.m2/repository/com/bekwam/examples-javafx-plugin-someplugin/1.0-SNAPSHOT/examples-javafx-plugin-someplugin-1.0-SNAPSHOT.jar";
	
	// on mac /Users/carlwalker/.m2/repository/com/bekwam/examples-javafx-plugin-someplugin/1.0-SNAPSHOT/examples-javafx-plugin-someplugin-1.0-SNAPSHOT.jar
	
	String pluginClass = 
			"com.bekwam.examples.javafx.plugin.someplugin.SomePlugin";

	VBox vbox = new VBox();
	
	Label label = new Label("JAR");
	TextField tfJarFile = new TextField();
	tfJarFile.setText( pathToPlugin );
	
	Label label_cl = new Label("Class");
	TextField tfClass = new TextField();
	tfClass.setText( pluginClass );
	
	Button load_b = new Button("Load Plugin");
	load_b.setOnAction((evt) -> {
		
		try {
			URL url = new URL("jar:file:" + tfJarFile.getText() + "!/");
		
			ClassLoader cl = new URLClassLoader( new URL[]{ url } );

			final Plugin plugin = (Plugin)Class.forName(tfClass.getText(), true, cl).newInstance();
		
			plugin.init();
			
			plugins.add( plugin );
			
		} catch(Exception exc) {
			exc.printStackTrace();
		}
	});
	
	ChoiceBox<Plugin> cb = new ChoiceBox<>();
	cb.itemsProperty().bind( new SimpleObjectProperty<ObservableList<Plugin>>(plugins) );
	
	Button b = new Button("Run Plugin");
	b.setOnAction( (evt) -> cb.getSelectionModel().getSelectedItem().operate() );
	
	vbox.setPadding(new Insets(40.0d));
	vbox.getChildren().addAll( label, tfJarFile, label_cl, tfClass, load_b, new Separator(), cb, b );
	
	Scene scene = new Scene(vbox, 1024, 768);
	
	primaryStage.setScene( scene );
	primaryStage.show();
}
 
Example 17
Source File: FxWebViewExample2.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final Stage stage)
{
	// Create the WebView
	WebView webView = new WebView();

	// Disable the context menu
	webView.setContextMenuEnabled(false);

	// Increase the text font size by 20%
	webView.setFontScale(1.20);

	// Set the Zoom 20%
	webView.setZoom(1.20);

	// Set font smoothing type to GRAY
	webView.setFontSmoothingType(FontSmoothingType.GRAY);

	// Create the WebEngine
	final WebEngine webEngine = webView.getEngine();
	// Load the StartPage
	webEngine.load("http://www.google.com");

	// Update the stage title when a new web page title is available
	webEngine.titleProperty().addListener(new ChangeListener<String>()
	{
	    public void changed(ObservableValue<? extends String> ov,
	            final String oldvalue, final String newvalue)
	    {
	    	stage.setTitle(newvalue);
	    }
	});

	// Create the VBox
	VBox root = new VBox();
	// Add the Children to the VBox
	root.getChildren().add(webView);

	// Set the Style-properties of the VBox
	root.setStyle("-fx-padding: 10;" +
			"-fx-border-style: solid inside;" +
			"-fx-border-width: 2;" +
			"-fx-border-insets: 5;" +
			"-fx-border-radius: 5;" +
			"-fx-border-color: blue;");

	// Create the Scene
	Scene scene = new Scene(root);
	// Add  the Scene to the Stage
	stage.setScene(scene);
	// Display the Stage
	stage.show();
}
 
Example 18
Source File: GroupLayersSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {

    // set the title and size of the stage and show it
    StackPane stackPane = new StackPane();
    Scene fxScene = new Scene(stackPane);
    stage.setTitle("Group Layers Sample");
    stage.setWidth(800);
    stage.setHeight(700);

    // create a JavaFX scene with a stackpane and set it to the stage
    stage.setScene(fxScene);
    stage.show();

    // create a scene view and add it to the stack pane
    sceneView = new SceneView();
    stackPane.getChildren().add(sceneView);

    // create a scene with a basemap and add it to the scene view
    scene = new ArcGISScene();
    scene.setBasemap(Basemap.createImagery());
    sceneView.setArcGISScene(scene);

    // set the base surface with world elevation
    Surface surface = new Surface();
    surface.getElevationSources().add(new ArcGISTiledElevationSource("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"));
    scene.setBaseSurface(surface);

    // create different types of layers
    ArcGISSceneLayer devABuildings = new ArcGISSceneLayer("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_BuildingShells/SceneServer");
    ArcGISSceneLayer devBBuildings = new ArcGISSceneLayer("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevB_BuildingShells/SceneServer");
    ArcGISSceneLayer devATrees = new ArcGISSceneLayer("https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_Trees/SceneServer");
    FeatureLayer devAPathways = new FeatureLayer(new ServiceFeatureTable(" https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/DevA_Pathways/FeatureServer/1"));
    FeatureLayer devProjectArea = new FeatureLayer(new ServiceFeatureTable("https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/DevelopmentProjectArea/FeatureServer/0"));

    // create a group layer from scratch by adding the layers as children
    groupLayer = new GroupLayer();
    groupLayer.setName("Group: Dev A");
    groupLayer.getLayers().addAll(Arrays.asList(devATrees, devAPathways, devABuildings));

    // add the group layer and other layers to the scene as operational layers
    scene.getOperationalLayers().addAll(Arrays.asList(groupLayer, devBBuildings, devProjectArea));

    // zoom to the extent of the group layer when the child layers are loaded
    groupLayer.getLayers().forEach(childLayer ->
      childLayer.addDoneLoadingListener(() -> {
        if (childLayer.getLoadStatus() == LoadStatus.LOADED) {
          sceneView.setViewpointCamera(new Camera(groupLayer.getFullExtent().getCenter(), 700, 0, 60, 0));
        }
      })
    );

    // create a JavaFX tree view to show the layers in the scene
    TreeView<Layer> layerTreeView = new TreeView<>();
    layerTreeView.setMaxSize(250, 200);
    TreeItem<Layer> rootTreeItem = new TreeItem<>();
    layerTreeView.setRoot(rootTreeItem);
    layerTreeView.setShowRoot(false);
    StackPane.setAlignment(layerTreeView, Pos.TOP_RIGHT);
    StackPane.setMargin(layerTreeView, new Insets(10));
    stackPane.getChildren().add(layerTreeView);

    // display each layer with a custom tree cell
    layerTreeView.setCellFactory(p -> new LayerTreeCell());

    // recursively build the table of contents from the scene's operational layers
    buildLayersView(rootTreeItem, scene.getOperationalLayers());

  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
Example 19
Source File: ChartAdvancedScatter.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override public void start(Stage primaryStage) throws Exception {
    init(primaryStage);
    primaryStage.show();
}
 
Example 20
Source File: ImageEditingApp.java    From FXTutorials with MIT License 4 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    stage.setScene(new Scene(createContent()));
    stage.show();
}