Accordion

Accordionレイアウトを提供する。
タイトルをクリックするとコンテンツが表示されるビューである。

javafx-container-accordion.png

サンプル Accordionの使用例

fileSampleAccordion.java

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);
    }

}

説明

参考リンク


添付ファイル: fileSampleAccordion.java 172件 [詳細] filejavafx-container-accordion.png 180件 [詳細]

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
目次
ダブルクリックで閉じるTOP | 閉じる
GO TO TOP