Code Source: class JFXComboboxExampleController.java package jfoenix_example; import com.jfoenix.controls.JFXComboBox; im...
Code Source:
class JFXComboboxExampleController.java
package jfoenix_example;
import com.jfoenix.controls.JFXComboBox;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.image.ImageView;
/**
* FXML Controller class
*
* @author amir
*/
public class JFXComboboxExampleController implements Initializable {
@FXML
private JFXComboBox<String> cb;
@FXML
void click(ActionEvent event) {
System.out.println(cb.getSelectionModel().getSelectedItem());
}
@Override
public void initialize(URL url, ResourceBundle rb) {
cb.getItems().add("Python");
cb.getItems().add("PHP");
cb.getItems().add("JAVA");
cb.getItems().add("C++");
}
}
JFXComboboxExample.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXComboBox?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/11.0.1" fx:controller="jfoenix_example.JFXComboboxExampleController">
<children>
<JFXComboBox fx:id="cb" focusColor="#00ff2f" layoutX="182.0" layoutY="110.0" prefHeight="30.0" prefWidth="248.0" promptText="Chose Language" unFocusColor="#ff0808" />
<JFXButton layoutX="254.0" layoutY="232.0" onAction="#click" prefHeight="30.0" prefWidth="103.0" style="-fx-background-color: green;" text="Click" />
</children>
</AnchorPane>
COMMENTS