Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
setValue()上的javafx选择框为空_Java_Javafx_Choice - Fatal编程技术网

setValue()上的javafx选择框为空

setValue()上的javafx选择框为空,java,javafx,choice,Java,Javafx,Choice,在我的项目中,我有一张桌子。当用户双击该行时,将打开一个编辑对话框。在打开此对话框时,我将值设置为字段,其中很少有选择框。ChoiceBox字段的类型是自定义对象,而不是字符串 创建以下对象的代码: 其中贸易点是贸易点类型的选择框。currentTradePoint不为空,当我查看trade_point的值等于currentTradePoint的值时,但在对话框中我没有看到任何值。项目设置正确。在另一种情况下,使用相同的选择框填充所有内容是正确的,而这里不是 UPD:TradePointConv

在我的项目中,我有一张桌子。当用户双击该行时,将打开一个编辑对话框。在打开此对话框时,我将值设置为字段,其中很少有选择框。ChoiceBox字段的类型是自定义对象,而不是字符串

创建以下对象的代码:

其中贸易点是贸易点类型的选择框。currentTradePoint不为空,当我查看trade_point的值等于currentTradePoint的值时,但在对话框中我没有看到任何值。项目设置正确。在另一种情况下,使用相同的选择框填充所有内容是正确的,而这里不是

UPD:TradePointConverter类:

    class TradePointConverter extends StringConverter<TradePoint>{
        public TradePoint fromString(String name){
            try {
                List<TradePoint> tradePoints = tradePointsService.getTradePoints();

                for (TradePoint tradePoint1: tradePoints){
                    if (tradePoint1.getName().equals(name)){
                        return tradePoint1;
                    }
                }
            }catch (SQLException e){

            }
            return null;
        }
        public String toString(TradePoint tradePoint1){
            return tradePoint1.getName();
        }
    }
class TradePointConverter扩展了StringConverter{
public TradePoint fromString(字符串名称){
试一试{
List tradePoints=tradePoints服务.getTradePoints();
用于(贸易点贸易点1:贸易点){
if(tradePoint1.getName().equals(name)){
返回交易点1;
}
}
}捕获(SQLE异常){
}
返回null;
}
公共字符串到字符串(贸易点贸易点1){
返回tradePoint1.getName();
}
}
我不确定这个转换器是否正确,因为按名称从字符串转换是完全不正确的。我不明白如何让用户正确地看到它(查看对象的名称),以及如何存储它的id以同时获得确定的对象。我可以通过获取id将其转换为字符串,但在这种情况下,用户不知道选择哪个对象

交易点是一个选择框:

private ChoiceBox<TradePoint> trade_point = new ChoiceBox<TradePoint>();
private ChoiceBox trade_point=new ChoiceBox();

我认为这与转换器密切相关。显示其代码。你确定这是choicebox而不是combobox吗?@UlukBiy看看update@silverest当我谈到ChoiceBox时,您建议我回答ComboBox,我认为它与转换器密切相关。显示其代码。你确定这是choicebox而不是combobox吗?@UlukBiy看看update@silverest当我谈到ChoiceBox时,你建议我回答ComboBox的问题
private ChoiceBox<TradePoint> trade_point = new ChoiceBox<TradePoint>();