Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Access restriction: The type JFrame is not accessible due to restriction on required library D:\Program Files\Java\jre1.7.0\lib\rt.jar
Access restriction: The method setDefaultLookAndFeelDecorated(boolean) from the type JFrame is not accessible due to restriction on required library D:\Program Files\Java\jre1.7.0\lib\rt.jar
Access restriction: The method setDefaultCloseOperation(int) from the type JFrame is not accessible due to restriction on required library D:\Program Files\Java\jre1.7.0\lib\rt.jar
Access restriction: The type JFrame is not accessible due to restriction on required library D:\Program Files\Java\jre1.7.0\lib\rt.jar
Access restriction: The field EXIT_ON_CLOSE from the type JFrame is not accessible due to restriction on required library D:\Program Files\Java\jre1.7.0\lib\rt.jar at Correct.main(Correct.java:33)
源码是
import java.awt.*;
import javax.swing.*;public class Correct extends JFrame{
private static int WIDTH = 400;
private static int HEIGHT = 400;
public Correct(){
super("基础案例,代码改错");
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();//get the size of screent
setLocation((d.width - WIDTH) / 2, (d.height - HEIGHT) / 2);//center the location
setSize( WIDTH, WIDTH );//set the size of window
setVisible( true );//display the window
}
public void paint( Graphics g ){
//super.paint(g);
g.setColor( new Color( 0,255,0 ));
g.drawOval( 150,140,100,110 );
g.setColor( new Color(255,255,0) );
g.fillOval( 150,140,100,110 );
int XPoint[] = {50,350,350,50,200};
int yPoint[] = {50,50,350,350,350};
Polygon polyRect = new Polygon(XPoint,yPoint,7);
g.setColor(Color.black);
g.drawPolygon( polyRect );
}
public static void main( String args[] ){
JFrame.setDefaultLookAndFeelDecorated(true);//set the feel of the window's look
Correct application = new Correct();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}
Access restriction: The type JFrame is not accessible due to restriction on required library D:\Program Files\Java\jre1.7.0\lib\rt.jar
Access restriction: The method setDefaultLookAndFeelDecorated(boolean) from the type JFrame is not accessible due to restriction on required library D:\Program Files\Java\jre1.7.0\lib\rt.jar
Access restriction: The method setDefaultCloseOperation(int) from the type JFrame is not accessible due to restriction on required library D:\Program Files\Java\jre1.7.0\lib\rt.jar
Access restriction: The type JFrame is not accessible due to restriction on required library D:\Program Files\Java\jre1.7.0\lib\rt.jar
Access restriction: The field EXIT_ON_CLOSE from the type JFrame is not accessible due to restriction on required library D:\Program Files\Java\jre1.7.0\lib\rt.jar at Correct.main(Correct.java:33)
源码是
import java.awt.*;
import javax.swing.*;public class Correct extends JFrame{
private static int WIDTH = 400;
private static int HEIGHT = 400;
public Correct(){
super("基础案例,代码改错");
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();//get the size of screent
setLocation((d.width - WIDTH) / 2, (d.height - HEIGHT) / 2);//center the location
setSize( WIDTH, WIDTH );//set the size of window
setVisible( true );//display the window
}
public void paint( Graphics g ){
//super.paint(g);
g.setColor( new Color( 0,255,0 ));
g.drawOval( 150,140,100,110 );
g.setColor( new Color(255,255,0) );
g.fillOval( 150,140,100,110 );
int XPoint[] = {50,350,350,50,200};
int yPoint[] = {50,50,350,350,350};
Polygon polyRect = new Polygon(XPoint,yPoint,7);
g.setColor(Color.black);
g.drawPolygon( polyRect );
}
public static void main( String args[] ){
JFrame.setDefaultLookAndFeelDecorated(true);//set the feel of the window's look
Correct application = new Correct();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货