Rumah  >  Artikel  >  pangkalan data  >  The type JOptionPane is not accessible due to restriction on

The type JOptionPane is not accessible due to restriction on

WBOY
WBOYasal
2016-06-07 15:37:291486semak imbas

今天在做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这个类,这样在这个文件中就能使用这个类了。
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn