Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3628076
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:58:11+00:00 2026-05-18T23:58:11+00:00

I am new to Mac OS X and is using version 10.6.5. JDK 1.6_u22

  • 0

I am new to Mac OS X and is using version 10.6.5. JDK 1.6_u22 seems to be preinstalled on the system. I have downloaded Eclipse 3.5.2.

It works fine if I create a simple hello world, but I can not import JFrame or use Swing. The error message that I get is:

Access restriction: The type JFrame is not accessible due to restriction on required library /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar

Here is the simple program that I have tried with:

import javax.swing.JFrame;

public class Test {

    public static void main(String[] args) {
        new JFrame();
    }
}

How do I use Java Swing in Eclipse on Mac OS X?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:58:12+00:00Added an answer on May 18, 2026 at 11:58 pm

    On Mac OS X 10.5.8, Eclipse 3.4.2 and Xcode 3.1.4, the example below builds and runs using recent revisions of either Java 1.5 or Java 1.6. As Xcode includes the JDK, what version of Mac OS X and Xcode are you using?

    Also verify that your Swing project hasn’t inadvertently included SWT.

    Addendum: Check these two dialogs:

    Eclipse > Preferences > Java > Build Path
    Eclipse > Preferences > Java > Installed JREs
    

    You should see references to /System/Library/Frameworks/JavaVM.framework/.

    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.*;
    
    public class X {
    
        public static void main(String[] args) {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(new JPanel() {
    
                private final int SIZE = 200;
                private final int INSET = 20;
    
                @Override
                public Dimension getPreferredSize() {
                    return new Dimension(SIZE, SIZE);
                }
    
                @Override
                public void paintComponent(Graphics g) {
                    super.paintComponent(g);
                    Graphics2D g2 = (Graphics2D) g;
    
                    g2.setColor(Color.blue);
                    Line2D line1 = new Line2D.Double(INSET, INSET,
                        getWidth() - INSET, getHeight() - INSET);
                    Line2D line2 = new Line2D.Double(getWidth() - INSET,
                        INSET, INSET, getHeight() - INSET);
                    g2.setStroke(new BasicStroke(16,
                        BasicStroke.CAP_ROUND,
                        BasicStroke.JOIN_BEVEL));
                    g2.draw(line1);
                    g2.draw(line2);
                }
            });
            frame.pack();
            frame.setVisible(true);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working in Eclipse on Mac. I am using PyDev version 2.6.0.2012062818. I
I am new to SQL.I have a database of mac-addresses which i created using
I am using Eclipse (Version: Indigo Service Release 2) on Mac OS X (10.7)
I am using Eclipse on Mac OX (I am new to Mac) and the
I've started using Coda because I just got a new Mac, and I want
I've used homebrew to install python on a new Mac Lion installation, and have
I have the certificates and keys on my new mac machine but when i
I am using zend Framework Version 1.11.11 and I work on a Mac (OSX
I am using MacBook Pro Mac OS 10.5 with related version of XCode. I
I am using MacBook Pro Mac OS 10.5 with related version of XCode. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.