Home  >  Article  >  Database  >  The type JOptionPane is not accessible due to restriction on

The type JOptionPane is not accessible due to restriction on

WBOY
WBOYOriginal
2016-06-07 15:37:291488browse

今天在做JAVA编程实验,在使用Eclipse编译时出现了以下编译错误: Access restriction: The type JOptionPane is not accessible due to restriction on required library D:\ProgramFiles\Java\jdk1.8.0\jre\lib\rt.jar 在网上搜了一下,解决办法是修改编译

  今天在做JAVA编程实验,在使用Eclipse编译时出现了以下编译错误:

Access restriction: The type JOptionPane is not accessible due to restriction on required library D:\Program Files\Java\jdk1.8.0\jre\lib\rt.jar

在网上搜了一下,解决办法是修改编译选项,方法如下:Window -> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rules) -> Warnings,或者在项目上修改编译选项。


import javax.swing.JOptionPane;
public class MyFirstApplication{
		public static void main(String[] args){
				JOptionPane.showMessageDialog(null,"Hello it is a joke!");
			}
	}

The type JOptionPane is not accessible due to restriction on

  import是引入的意思,javax.swing是sun为我们提供的一个包,包中有一个类叫 JOptionPane。
JOptionPane是有助于方便地弹出要求用户提供值或向其发出通知的标准对话框。它是用来编写图形用户界面的一个类。

合起来讲就是:导入包javax.swing中JOptionPane这个类,这样在这个文件中就能使用这个类了。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn