How to create a javafx 2.0 application MDI


Question

How to implement something kinda internal frame in JavaFx 2.0 specifically?

My attempt is as so..

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main extends Application {

    ConnectDb connection;

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

    @Override
    public void start(Stage stage) throws Exception {
        final Stage stage1 = new Stage();
        StackPane pane = new StackPane();
        Button btn = new Button("Click Me");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                connection = new ConnectDb();
                try {
                    connection.start(stage1);
                } catch (Exception e) {
                    e.printStackTrace(); 
                }
                System.out.println("Fire some thing..");
            }
        });
        pane.getChildren().add(btn);
        stage.setScene(new Scene(pane ,200, 300));
        stage.show();
    }
}

ConnectDb.java

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class ConnectDb extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        StackPane pane = new StackPane();
        Button btn = new Button("Click On Button which is me");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                System.out.println("Something here..");
            }
        });
        pane.getChildren().add(btn);
        stage.setScene(new Scene(pane ,200, 300));
        stage.show();
    }
}
1
0
6/2/2016 1:13:46 PM

  1. Create parent AncorPane.
  2. Add several children AnchorPanes to it. They will serve as internal frames. Add different content to these.
  3. Set children AnchorPanes invisible.
  4. Add buttons to hide, resize or close children AnchorPanes. When needed, call function to set all children AnchorPanes invisible, except for one.
1
6/5/2013 4:58:24 PM

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