0

I want to make a game, and for that I want to make a JFrame to contain it in. However: I've followed many tutorials on YouTube on how to set one up. I am certain that I have the latest version of Java. It will not let me import it, for some reason. When I highlight the error underneath JFrame, it doesn't let me import it. It just says that it can't be resolved to a type, and gives me these options: "Create class 'JFrame'," or "Fix project startup..."

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Ctsmario
  • 21
  • 6
  • http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.wb.swing.doc.user%2Fhtml%2Fwizards%2Fswing%2Fjframe.html – Semih Eker Feb 20 '15 at 23:38
  • Have you tried to manually import it? : `import javax.swing.JFrame;` – engineercoding Feb 20 '15 at 23:39
  • I just tried, and it gave me this error: Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jre1.8.0_31\lib\rt.jar – Ctsmario Feb 20 '15 at 23:40
  • http://stackoverflow.com/a/2174607/3554071 - That should fix your problem – engineercoding Feb 20 '15 at 23:47
  • @codequestioneer Well...that worked. Thanks! Could you possibly explain what was wrong, though? Or why that worked? Just so I could maybe prevent future occurrences. – Ctsmario Feb 20 '15 at 23:52
  • But the puzzle is why it is necessary to do that for `javax.swing.JFrame`? Are you trying to write this as an Android app or a JavaME App? If so, you *shouldn't* be trying to use Swing. – Stephen C Feb 20 '15 at 23:53
  • I was just trying to make a little 2D game so I could get used to how Java works. @StephenC – Ctsmario Feb 20 '15 at 23:54
  • The only thing I can think of is that you were previously using your Eclipse workspace for Android or JavaME development ... and your project has inherited settings that are appropriate to that rather than Java SE. – Stephen C Feb 20 '15 at 23:56
  • I was trying this one series of web tutorials that used the LibGDX library, and I was forced to make an android-project for it to work. Maybe that's why? @StephenC – Ctsmario Feb 20 '15 at 23:57
  • Possibly. I would expect that Eclipse would configure itself to stop you accessing Swing classes in Android apps ... 'cos they are not appropriate. – Stephen C Feb 21 '15 at 00:00

0 Answers0