Olá pessoal estou com uma dúvida na hora de popular o meu combobox, estou implementando este projeto com arquitetura MVC, então eu precisava que esse combobox force popularizado dentro da minha controller, porém não estou conseguindo fazer com que ela seja executada no momento que roda a cena.
package com.pontoDigital.Controllers;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
public class ControllerThree{
ObservableList<String> opFunc = FXCollections.observableArrayList(
"Efetivo",
"Estagiário");
@FXML
ComboBox cbFunc;
//Esse será o evento do clicked on mouse
public void tipoFuncionarios() {
cbFunc = new ComboBox(opFunc);
}
}
Esse seria o FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.pontoDigital.Controllers.ControllerThree">
<children>
<AnchorPane prefHeight="400.0" prefWidth="300.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Button layoutX="107.0" layoutY="245.0" mnemonicParsing="false" text="Gravar ao BD" />
<Label layoutX="14.0" layoutY="33.0" text="Tipo:" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="30.0">
<font>
<Font name="Arial Black" size="12.0" />
</font>
</Label>
<Label layoutX="9.0" layoutY="73.0" text="Nome:" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="80.0">
<font>
<Font name="Arial Black" size="12.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="103.0" text="CPF:" AnchorPane.topAnchor="120.0">
<font>
<Font name="Arial Black" size="12.0" />
</font>
</Label>
<TextField layoutX="75.0" layoutY="68.0" />
<TextField layoutX="75.0" layoutY="116.0" />
<ComboBox fx:id="cbFunc" layoutX="75.0" layoutY="26.0" onMouseClicked="#tipoFuncionarios" prefWidth="150.0" promptText="Selecione" visibleRowCount="2" />
</children>
</AnchorPane>
</children>
</AnchorPane>