aspose file tools*
The moose likes Beginning Java and the fly likes Error runnning program using javx.swing in jcreator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error runnning program using javx.swing in jcreator" Watch "Error runnning program using javx.swing in jcreator" New topic
Author

Error runnning program using javx.swing in jcreator

Mitchell Mock
Greenhorn

Joined: Nov 03, 2005
Posts: 2
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
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
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
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14433
    
  23

The error tells you exactly what you should do: Do not use javax.swing.JFrame.add() use javax.swing.JFrame.getContentPane().add() instead... :roll:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Stephen Boston
Ranch Hand

Joined: Jul 14, 2005
Posts: 165
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!


Steve<br /> <br />No matter where you go, there you are.<br /> <br />"My evil self is at the door, and I have no power to stop it."
Mitchell Mock
Greenhorn

Joined: Nov 03, 2005
Posts: 2
Thanks for the help
I updated to 1.5 Jre. I thought I had it but it was 1.4


Thanks again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error runnning program using javx.swing in jcreator