私は今日JavaFXを使い始めましたが、すでにアドバイスが必要です。MainApplication (ファイルに ApplicationController が指定されている)applicaton.fxml
のメソッドで FXMLLoader を使用して、(Oracle SceneBuiler で作成された) をロードします。start(Stage ...)
application.fxml
<AnchorPane id="AnchorPane" disable="false" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0" styleClass="theme" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="app.AppController">
...more code here...
<ComboBox id="cmb_locations" fx:id="cmb_locations">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Item 1" />
<String fx:value="Item 2" />
<String fx:value="Item 3" />
</FXCollections>
</items>
</ComboBox>
これで、 に があり、ComboBox
3applicaton.fxml
つのアイテム (既定のアイテム) があります。必要なのはComboBox
、起動時に独自の値を入力することです。app.AppController
それを達成する方法と、関連するコードスニペット(または同様のもの)をどこに配置するかを知っている人はいますか? 前もって感謝します。