使用eclipse在jdk 1.8中实现swing [英] Implementing swing in jdk 1.8 using eclipse

查看:254
本文介绍了使用eclipse在jdk 1.8中实现swing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 jdk 1.8 中使用 eclipse 来实现swing的概念,但当我使用标识符时 JButton 然后出现错误:

I was trying to implement the concept of swing using eclipse in jdk 1.8 but when I used the identifier like JButton then an error came :

The type JButton is not accessible due to restriction on required library C:\ProgramFiles
\Java\jre 1.8.0_31\lib\rt.jar

我是一名新手Java程序员。有人可以帮我解决这个错误吗?

I am a newbie Java programmer.Can someone please help me out with this error?

推荐答案

您的项目设置错误。一个古老的问题可以在这里找到/ a>有相同的问题(以及解决问题的正确方法)。

Your project settings are wrong. An ancient question can be found here with the same issue (and the correct way to resolve it).

基本上你需要检查项目的构建路径确保它引用了默认的 JRE ,并且你没有从其他地方包含Swing类导致冲突:Eclipse看到你正在尝试从 foobar.jar 使用类 JButton 而不是 rt.jar 并且说它不对。

Basically you need to check your project's Build Path to make sure that it's referring to the default JRE and you're not including the Swing classes from somewhere else causing a conflict: Eclipse sees that you're trying to use class JButton from foobar.jar instead of rt.jar and is saying that it's not right.

这篇关于使用eclipse在jdk 1.8中实现swing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆