JAVA swing组件 基本定义 我的 frame.add(button);这里一直报错,不知道是什么原因
packageJFrametext;importjavax.swing.JButton;importjavax.swing.JFrame;publicclassTEXT0...
package JFrametext;
import javax.swing.JButton;
import javax.swing.JFrame;
public class TEXT01 {
public static void main(String[] args) {
JFrame frame = new JFrame();
JButton button = new JButton();
frame.add(button);
}
}
错误显示的是The method add(Component) in the type Container is not applicable for the arguments (JButton)
- The type javax.swing.JComponent cannot be resolved. It is indirectly referenced from 展开
import javax.swing.JButton;
import javax.swing.JFrame;
public class TEXT01 {
public static void main(String[] args) {
JFrame frame = new JFrame();
JButton button = new JButton();
frame.add(button);
}
}
错误显示的是The method add(Component) in the type Container is not applicable for the arguments (JButton)
- The type javax.swing.JComponent cannot be resolved. It is indirectly referenced from 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询