#author("2018-05-08T14:18:50+00:00","default:haikikyou","haikikyou")
[[JavaFX]]
* コンテナ [#w6446a3f]
- UI部品のレイアウトを整えるベース部分である。
- 行、列、重なりやタイル配置など様々なクラスがある。
- Windowのリサイズで自動的に配置とサイズを変更してくれる機能がある。
テキストフィールドやラベル、ボタンなど、この
* Accordion [#l8ed6376]
Accordionレイアウトを提供する。~
タイトルをクリックするとコンテンツが表示されるビューである。
#ref(./javafx-container-accordion.png)
#geshi(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.stage.Stage;
/**
*
* @author t-moriyasu
*/
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 TextArea("content3"));
// 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);
// 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);
}
}
}}}