File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JFrame application HELP Needed ! ! ! (STILL NEED HELP) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame application HELP Needed ! ! ! (STILL NEED HELP)" Watch "JFrame application HELP Needed ! ! ! (STILL NEED HELP)" New topic
Author

JFrame application HELP Needed ! ! ! (STILL NEED HELP)

Douglas Braxton
Ranch Hand

Joined: Jan 28, 2004
Posts: 36
Ranch Hands:

There is a lot of code here. Do not let it throw you. Most of it is here to avoid having to repost it if someone has a question
The problem lies within the statement followed by this comment (I think)
// # # # PROBLEM # # # in class MYFrame.
All code compiles clean.
OBJECT: Illustrate inheritance exercise which will have 15 random shapes drawn on a JFrame.
PROBLEM: When I execute the Driver the JFrame is BLANK. If you drag the frame the program executes as expected but it produces the following list of runtime errors:
java.lang.NullPointerException
at MyFrame.paint(MyFrame.java:55)
at sun.awt.RepaintArea.paint(RepaintArea.java:177)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)
at java.awt.Component.dispatchEventImpl(Component.java:3699)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Window.dispatchEventImpl(Window.java:1590)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
Thanks for your expert help.
75gator


[ April 13, 2004: Message edited by: Douglas Braxton ]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Swing / JFC / AWT forum, where they love to get all messy with this GUI stuff...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Polina Bee
Greenhorn

Joined: Feb 17, 2004
Posts: 6
Hi Douglas.
Just make setVisible(true) the last opeation in MyFrame constructor or remove it from constructor at all and put to the main function like this:
public static void main (String[ ] arg)
{
MyFrame mFrame = new MyFrame();
mFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
mFrame.setVisible(true);
//System.exit(0);
}// terminate main
}// end of MyShapesDriver
Like it id now, your program tries to draw shapes before you create them and you're getting the NullPointerException.
Good luck.
Polina
Douglas Braxton
Ranch Hand

Joined: Jan 28, 2004
Posts: 36
Thanks for the help. Problem solved!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame application HELP Needed ! ! ! (STILL NEED HELP)
 
Similar Threads
Braincramp regarding classes
Problems with Threads in an Applet
Declaring an array of objects of a class ???
I need experienced replies only regarding coding standards!
Braincramp regarding classes