Accordion †
Accordionレイアウトを提供する。
タイトルをクリックするとコンテンツが表示されるビューである。
サンプル Accordionの使用例
package sample; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Accordion; import javafx.scene.control.TextArea; import javafx.scene.control.TitledPane; import javafx.scene.web.WebView; import javafx.stage.Stage; public class SampleAccordion extends Application { /** * Initialize stage and start scene. * * @param primaryStage * @throws Exception */ @Override public void start(Stage primaryStage) throws Exception { // Create accordion. Accordion acc = new Accordion(); // Create panes. TitledPane pane1 = new TitledPane("pane1", new TextArea("content1")); TitledPane pane2 = new TitledPane("pane2", new TextArea("content2")); TitledPane pane3 = new TitledPane("pane3", new WebView()); // Add panes to the accordion container. acc.getPanes().add(pane1); acc.getPanes().add(pane2); acc.getPanes().add(pane3); // When the stage is shown, make pane1 opened. acc.setExpandedPane(pane1); // Load a webpage when page3 is opened. pane3.setOnMousePressed(event -> { WebView wv = (WebView)pane3.getContent(); if (wv.getEngine().getLocation() == null) { wv.getEngine().load("https://haikikyou.xsrv.jp/pwiki/"); } }); // Create a scene Scene scene = new Scene(acc); primaryStage.setScene(scene); // Show window. primaryStage.show(); } /** * Launch application. * * @param args */ public static void main(String[] args) { launch(args); } }
説明
- Accordionに3つのペインを追加している。
- 3つのうち2つのペインは、テキストエリア、1つはWebビューである。
- WebViewは、初回にロードされた時に、指定のURLからコンテンツをロードする。