解析类型 javax.swing.JComponent的问题处理

来源:互联网 发布:淘宝浩升软件什么用途 编辑:程序博客网 时间:2024/05/22 17:04
无法解析类型 javax.swing.JComponent。从必需的 .class 文件间接引用了它,菜鸟求解答,求赐教?
package bo;import java.awt.EventQueue;import javax.swing.JFrame;public class RunDialogDemo {private JFrame frame;/** * Launch the application. */public static void main(String[] args) {EventQueue.invokeLater(new Runnable() {public void run() {try {RunDialogDemo window = new RunDialogDemo();window.frame.setVisible(true);} catch (Exception e) {e.printStackTrace();}}});}/** * Create the application. */public RunDialogDemo() {initialize();}/** * Initialize the contents of the frame. */private void initialize() {frame = new JFrame();frame.setBounds(100, 100, 450, 300);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.getContentPane().setLayout(null);}}


回答:你要用哪个类,你就要导入 import javax.swing.JFrame; 这里导入了JFrame ,再次使用这个语句导入 import  java.swing.JComponent; 就好了。如果导入之后,导入的这句话有红叉,显示无法解析导入的这句话,可能是你jar包的路径问题。
0 0
原创粉丝点击