Sunday, April 13, 2014

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?































































No comments:

Post a Comment