この内部フレームの例を見つけました
http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html
JavaFXで同じ内部フレームを作成することは可能ですか?
この内部フレームの例を見つけました
http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html
JavaFXで同じ内部フレームを作成することは可能ですか?
JFXtrasには、コンテンツを追加して内部ウィンドウの動作を処理できる Window コントロールがあります。
まず、クラスパスに jfxtras ライブラリを配置する必要があります。ライブラリを入手できる手順がいくつかあります。Maven を使用している場合は、以下を追加するだけです。
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-labs</artifactId>
<version>2.2-r5</version>
</dependency>
または、ライブラリをダウンロードして、プロジェクトのクラスパスに配置します。
ここで、いくつかのウィンドウを生成できるように、少し違いのあるウィンドウのデモのサンプルを置きます。
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");
root.getChildren().addAll(button);
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 600, 500));
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
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)
w.setLayoutX(10);
w.setLayoutY(10);
// 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
root.getChildren().add(w);
}
});
}
public double getSampleWidth() {return 600;}
public double getSampleHeight() {return 500;}
@Override
public void start(Stage primaryStage) throws Exception {
init(primaryStage);
primaryStage.show();
}
public static void main(String[] args) {launch(args);}
}
元のデモでは、イベント コードは init メソッドにあり、ボタンは含まれていませんでした。ボタンを追加して動的にウィンドウを作成し、それらを画面に追加します。
アプリケーションの結果のスナップショットを次に示します。
jfxtras のデモを試すことを強くお勧めします。彼らは本当に素晴らしいものを持っています。それが役に立てば幸い。