This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide this week in the Jobs Discussion 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

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:
at MyFrame.paint(
at sun.awt.RepaintArea.paint(
at java.awt.Component.dispatchEventImpl(
at java.awt.Container.dispatchEventImpl(
at java.awt.Window.dispatchEventImpl(
at java.awt.Component.dispatchEvent(
at java.awt.EventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(
Thanks for your expert help.

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

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

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 );
}// 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.
Douglas Braxton
Ranch Hand

Joined: Jan 28, 2004
Posts: 36
Thanks for the help. Problem solved!
I agree. Here's the link:
subject: JFrame application HELP Needed ! ! ! (STILL NEED HELP)
jQuery in Action, 3rd edition