Results 1 to 4 of 4
  1. #1
    chassconcept is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Default Need help with JFrames

    I am new to java and beggining to learn how to write programs. I use eclipse and when I try to import JFrame it tells me that access is restricted. I already changed the permission settings of rt.jar but it is not working still. Please I need your help.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default Re: Need help with JFrames

    If you want help, you'll have to provide the exact code and exact error message you're talking about.

    Try taking netbeans out of the picture. Can you compile something that uses a JFrame from the command prompt?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    chassconcept is offline Member
    Join Date
    Jun 2012
    Posts
    2
    Rep Power
    0

    Default Re: Need help with JFrames

    This is the code and the error message. Thanks.

    package intro;
    import java.awt.Canvas;
    import java.awt.Graphics;
    import javax.swing.JFrame;
    public class MyCanvas extends Canvas {
    public static void main(String[] args) {
    // make the frame
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
    // add the canvas
    Canvas canvas = new MyCanvas();
    canvas.setSize(400, 400);
    frame.getContentPane().add(canvas);
    // show the frame
    frame.pack();
    frame.setVisible(true);
    }
    public void paint(Graphics g) {
    // draw a circle
    g.fillOval(100, 100, 200, 200);
    }
    }


    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar
    Access restriction: The constructor JFrame() is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar
    Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar
    Access restriction: The method setDefaultCloseOperation(int) from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar
    Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar
    Access restriction: The field EXIT_ON_CLOSE from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar
    Access restriction: The method getContentPane() from the type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jre7\lib\rt.jar

    at intro.MyCanvas.main(MyCanvas.java:8)[/COLOR]

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need help with JFrames

    I've never seen that error before. Consider re-installing Java. When you get Java working, I advise you not to use AWT components, such as Canvas objects, with a Swing GUI.

Similar Threads

  1. JFrames
    By asmitarnd in forum AWT / Swing
    Replies: 1
    Last Post: 04-11-2011, 01:10 PM
  2. need help with jframes
    By glomic in forum New To Java
    Replies: 13
    Last Post: 01-08-2011, 12:16 PM
  3. help with jframes
    By pao09 in forum AWT / Swing
    Replies: 0
    Last Post: 04-15-2009, 03:10 PM
  4. jframes
    By ddj in forum AWT / Swing
    Replies: 0
    Last Post: 03-24-2009, 04:15 PM
  5. two JFrames
    By kirtesh4u in forum New To Java
    Replies: 0
    Last Post: 11-17-2008, 09:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •