This question already has answers here:
How to pass number to TextField JavaFX?
                                
                                    (3个答案)
                                
                        
                                3年前关闭。
            
                    
如何将文本字段设置为int类型?
就像我有这行代码一样:
appointmentText.setText(pa.getindex());

如果appointmentText是textField并且pa.getindex();从另一个类获取一个int类型

最佳答案

使用String.valueOf()

appointmentText.setText(String.valueOf(pa.getindex());


顺便说一句,getindex()应该遵循驼峰式命名约定。

09-11 06:11