Monday Apr 22, 2013

New documentation: Using Scene Builder with Java IDEs

A new JavaFX Scene Builder 1.1 developer preview documentation, Using Scene Builder with Java IDEs, has been published on http://docs.oracle.com/javafx. It describes how you can use NetBeans IDE, Eclipse, and IntelliJ IDEA to easily create a JavaFX project and edit an FXML file with Scene Builder to build your application's UI.

You can download the latest Scene Builder 1.1 developer preview build from the JavaFX Scene Builder Developer Preview Download page. Use the Scene Builder 1.1 Developer Preview Release Notes for information about system requirements, installation information, and new or modified features.

Friday Nov 18, 2011

JavaFX: Use a Screen with your Scene!

Here's a handy tip for sizing your application. You can use the javafx.stage.Screen class to obtain the width and height of the user's screen, and then use those same dimensions when sizing your scene. The following code modifies default "Hello World" application that appears when you create a new JavaFX project in NetBeans.

package screendemo;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.stage.Screen;
import javafx.geometry.Rectangle2D;

public class ScreenDemo extends Application {

    public static void main(String[] args) {
        Application.launch(args);
    }
    
    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Hello World");
        Group root = new Group();
        Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
        Scene scene = new Scene(root, screenBounds.getWidth(), screenBounds.getHeight());   
        Button btn = new Button();
        btn.setLayoutX(100);
        btn.setLayoutY(80);
        btn.setText("Hello World");
        btn.setOnAction(new EventHandler() {

            public void handle(ActionEvent event) {
                System.out.println("Hello World");
            }
        });
        root.getChildren().add(btn);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

Running this program will set the Stage boundaries to visible bounds of the main screen.

-- Scott Hommel

About

Blog about Java technology documentation and news about Java releases.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today