Internal Frames in JavaFX


I found this example of Internal Frames

Is it possible to make the same internal Frames in JavaFX?

7/16/2013 9:49:17 AM

With JFXtras there is a Window control, where you can add content and handle the internal window behavior.

First you will need to put in your classpath the jfxtras library. They have some instructions where you can get the library. If you are using maven, just need to add:


Or download the library and put it into your project classpath, whatever.

Now I put a sample of the demo of the Window with a little difference, allowing generation of several windows.

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.scene.control.Label;
import javafx.stage.Stage;
import jfxtras.labs.scene.control.window.CloseIcon;
import jfxtras.labs.scene.control.window.MinimizeIcon;
    import jfxtras.labs.scene.control.window.Window;

public class WindowTests extends Application {
private static int counter = 1;

private void init(Stage primaryStage) {
    final Group root = new Group();

    Button button = new Button("Add more windows");     

    primaryStage.setScene(new Scene(root, 600, 500));

    button.setOnAction(new EventHandler<ActionEvent>() {            
        public void handle(ActionEvent arg0) {
            // create a window with title "My Window"
            Window w = new Window("My Window#"+counter);
            // set the window position to 10,10 (coordinates inside canvas)
            // define the initial window size
            w.setPrefSize(300, 200);
            // either to the left
            w.getLeftIcons().add(new CloseIcon(w));
            // .. or to the right
            w.getRightIcons().add(new MinimizeIcon(w));
            // add some content
            w.getContentPane().getChildren().add(new Label("Content... \nof the window#"+counter++));
            // add the window to the canvas

public double getSampleWidth() {return 600;}
public double getSampleHeight() {return 500;}

public void start(Stage primaryStage) throws Exception {

    public static void main(String[] args) {launch(args);}

In the original demo, the event code was in the init method, and no button was included. I add the button to create dynamically windows and adding them to the screen.

Here is a snapshot of the result of the application:


I totally recommend you try the demo of jfxtras. They have really great stuff. Hope it helps.

7/17/2013 7:42:04 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow