Results 1 to 2 of 2
  1. #1
    ConTec is offline Member
    Join Date
    Apr 2014
    Location
    Plattsburgh, NY
    Posts
    2
    Rep Power
    0

    Default Question: Why is Eclipse picking and choosing what to import?

    So, I'm following a tutorial in the tutorial I'm using JFrame. I understand that when you hit Ctrl+Shift+O in Eclipse, it should automatically add this as an import:

    Java Code:
    import javax.swing.JFrame;
    However, it didn't do that. When I add that line of code manually, it still works and I can run the code without error.

    Next I had to import 'Graphics' from java.awt.Graphics, so when I typed this code:

    Java Code:
    public void paint(Graphics g){
    }
    And then hit Ctrl+Shift+O, Eclipse automatically added the import line of code to the top of class.


    So why did it do this for 'Graphics' but not for 'JFrame' even though it understands both imports? Is this something I need to do in Eclipse to make it "sync" all the available Java classes I have available or something?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,021
    Rep Power
    6

    Default Re: Question: Why is Eclipse picking and choosing what to import?

    It should have added the JFrame import for you. Eclipse may have been confused for some reason (I occasionally but rarely experience similar behavior). But it will either add it for you or give you a choice if more than one class with that name exists.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Help with import in Eclipse
    By gorgon777 in forum New To Java
    Replies: 12
    Last Post: 01-03-2014, 08:44 PM
  2. How to import web app to eclipse ????
    By mlotfi in forum Eclipse
    Replies: 0
    Last Post: 02-25-2012, 06:07 AM
  3. Eclipse 3.5<import *.jar -Need help>
    By roughjj in forum Eclipse
    Replies: 1
    Last Post: 09-09-2009, 10:24 AM
  4. How to import a package in Eclipse?
    By naipulb in forum New To Java
    Replies: 2
    Last Post: 06-09-2008, 12:04 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
  •