一段简单程序, frame.add(lbl);出现 问题。 也不知道为什么就是这里, 而我Ctrl + Shift + T 确实也是没有发现 JComponent 。

public void displayImage(String title, Image img, int x, int y)
{
ImageIcon icon=new ImageIcon(img);
JFrame frame=new JFrame(title);
JLabel lbl=new JLabel(icon);
frame.add(lbl);// ERROR
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocation(x, y);
frame.setVisible(true);
}

奇了怪了!我猜是jdk版本的问题,但是为什么呢? 难道不能用jdk8 ? 可是项目的其他代码都是依赖jdk8 的?

网上查看半天没有找到解决方案! stackoverflow 也没有! 郁闷! 后面偶然发现这个 :

http://blogs.candoerz.com/question/155925/java-swing-component-cannot-be-resolved.aspx

我大概明白了,应该还是jdk8 在myeclipse10 的不兼容的问题。 具体来说是我的 myeclipse10 的java compliation level 只能是 7, 所以。。。

换成 ideaj, 问题解决! 又是 jdk8 在myeclipse 的不兼容的问题啊!

The type javax.swing.JComponent cannot be resolved. It is indirectly referenced from required .class files的更多相关文章

  1. eclipse中java文件报错:The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

    问题:The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class fi ...

  2. The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files

    最近在做J2ME开发项目,配置环境一切OK,但是打开项目时某些文件提示: The type java.lang.String cannot be resolved. It is indirectly ...

  3. 部署hibernate框架项目时出现问题:The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files.

    基本情况: (这些其实关系不大)我是直接impor导入HibernateDemo项目到eclipse中的,该项目的hibernate版本是3.6.7.Final版,使用了Hibernate Tools ...

  4. The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

    The type java.lang.Object cannot be resolved.It is indirectly referenced from required .class files ...

  5. 问题1-The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files

    问题一:The type java.lang.String cannot be resolved. It is indirectly referenced from required .class f ...

  6. The type java.lang.AutoCloseable cannot be resolved. It is indirectly referenced from required .class files

    出现问题: The type java.lang.AutoCloseable cannot be resolved. It is indirectly referenced from required ...

  7. The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files.

    参照 http://stackoverflow.com/questions/24301986/the-type-java-lang-charsequence-cannot-be-resolved-in ...

  8. java报错:The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

    看包的路径是否对对:比如这样不对(...src/object/obietc) 其它解决方法转载: https://www.cnblogs.com/yadongliang/p/5918228.html ...

  9. 当你在web项目下新建一个class时package位置如果发生红色波浪错误,提示为”The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files“

    问题是这样的如下图: 问题的原因: 1.配置tomcat7.0的时候自己设置了jre的版本1.8,而没有用myeclipse10自带的jre1.6,导致了出现了差错!

随机推荐

  1. C++进阶--类的继承

    //############################################################################ /* * 公有,保护,私有继承 */ cl ...

  2. Ubuntu 下Android Studio基本配置

    一.界面设置(主题设置) 默认的 Android Studio 为灰色界面,可以选择使用炫酷的黑色界面.Settings --> Appearance --> Theme ,选择 Darc ...

  3. 通过编写PHP代码并运用“正则表达式”来实现对试题文档进行去重复、排序

    通过编写PHP代码并运用“正则表达式”来实现对试题文档进行去重复.排序 <?php $subject = file_get_contents('test.txt'); $pattern = '/ ...

  4. MySQL 二进制文件恢复数据基础版本

    先来一段 自行体会 #---------------------------------------------------------------------------------- #模拟通过b ...

  5. MySQL 独立表空间恢复案例

    创建表的时候就会得到元数据.可以通过定义的方式对表的元数据进行生成 这个地方要注意的是 独立表空间当中   ibd & frm分别存储的是什么数据? 表空间:文件系统,为了更好的扩容数据库的存 ...

  6. dialog--not attached to window manager

    该异常表示view没有添加到窗口管理器,通常是我们dismiss对话框的时候,activity已经不存在了,建议不要在非UI线程操作对话框. [解决方案]:常发生这类Exception的情形都是,有一 ...

  7. [UE4]第一人称与第三人称

    一.给Character添加一个SkeletalMesh,并设置为第三人称模型.并设置自己看不到该模型. 二.添加给骨骼的右手添加一个Socket插槽用来挂载武器 三.判断当前角色是否被本地Contr ...

  8. [UE4]传送门:场景切换

  9. NameNode配置HA后及其反过程Hive路径不正确的问题解决

    在CDH5.7下,配置了NameNode的HA后,Hive无正常查询数据了,但是其他的组件HDFS , HBase ,Spark都正常的.Hive新建表出现如下异常: CREATE TABLE `x_ ...

  10. 软硬链接ln

    1:软链接 -- 快捷方式 I:ln -s 文件名 快捷方式的名字 文件名:使用绝对路径 II':目录也可以创建链接 2:硬链接 I: ln 文件名 硬链接的名字