"특수 값"(예 : 빈 문자열)이있는 항목을 콤보 상자의 항목 목록 끝에 추가 할 수 있습니다.
셀 팩터 리를 사용하여 해당 값이 표시되면 사용자에게 친숙한 메시지 (예 : "항목 추가 .."등)를 사용자에게 표시하는 셀을 만듭니다. 셀에 특수 값을 표시하는 경우 새 값을 입력하기위한 대화 상자를 표시하는 셀에 이벤트 필터를 추가하십시오.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ListCell;
import javafx.scene.control.TextInputDialog;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class AddItemToComboBox extends Application {
@Override
public void start(Stage primaryStage) {
ComboBox<String> combo = new ComboBox<>();
combo.getItems().addAll("One", "Two", "Three", "");
combo.setCellFactory(lv -> {
ListCell<String> cell = new ListCell<String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
} else {
if (item.isEmpty()) {
setText("Add item...");
} else {
setText(item);
}
}
}
};
cell.addEventFilter(MouseEvent.MOUSE_PRESSED, evt -> {
if (cell.getItem().isEmpty() && ! cell.isEmpty()) {
TextInputDialog dialog = new TextInputDialog();
dialog.setContentText("Enter item");
dialog.showAndWait().ifPresent(text -> {
int index = combo.getItems().size()-1;
combo.getItems().add(index, text);
combo.getSelectionModel().select(index);
});
evt.consume();
}
});
return cell ;
});
BorderPane root = new BorderPane();
root.setTop(combo);
Scene scene = new Scene(root, 400, 400);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

그래서 당신은 당신이 사용자가 가능한 옵션 목록에 추가 할 수 있도록하거나 두 개의 필드가 있거나 할 뜻 : 여기
빠른 SSCCE입니다 편집 가능한 콤보 박스를 원하십니까? – MadProgrammer