javax.swing.JTextField cannot be cast to java.awt.TextField

2024-12-23 13:32:49
推荐回答(2个)
回答1:

你是不是使用了TextField来实例化JTextField啊??JTextField不是继承自TextField的!!!而是
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
明白!!?

回答2:

javax.swing.JTextField cannot be cast to java.awt.TextField

JTextField f=new JTextField (10);