• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error runnning program using javx.swing in jcreator

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a beginner using one of O'Reillys beginning java. One of the first examples in the book causes the following error from trying to run this Java program.


Exception in thread "main" java.lang.Error: Do not use javax.swing.JFrame.add() use javax.swing.JFrame.getContentPane().add() instead

at javax.swing.JFrame.createRootPaneException(JFrame.java:465)
at javax.swing.JFrame.addImpl(JFrame.java:491)
at java.awt.Container.add(Container.java:307)
at HelloJava.main(HelloJava.java:37)

I am using jCreator 3.5 It runs fine in Textpad fine but I need to get it to work in jCreator

It complies in both
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.

Wlecome aboard.

I think you need to check the version of JDK your JCreator is using. In J2SE5.0 you can say JFrame.add(), but in older versions you had to say JFrame.getContentPane().add().
Your JCreator might be using J1.4, in which case you need to alter the path in JCreator.
CR
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error tells you exactly what you should do: Do not use javax.swing.JFrame.add() use javax.swing.JFrame.getContentPane().add() instead... :roll:
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mitchell,

JCreator installs its own JDK. It may be different from the one you installed.

If you go to the configure menu and select options and then Profiles you can see what JDK it is using. You can also change the profile (or add a new one) to point to the newer version of the JDK you have installed.

HTH!
 
Mitchell Mock
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help
I updated to 1.5 Jre. I thought I had it but it was 1.4


Thanks again
 
reply
    Bookmark Topic Watch Topic
  • New Topic