• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating Dialogs

 
jays kays
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im having some problems creating and using dialogs.My code is pretty much based on the following:




As far as i can see i've referenced my frame correctly.But i get the following error,which seems to relate to the lines



My code compiles correctly and runs but when i select the button which will start up the dialog I get the folowing error.

 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

I have said it before on the Ranch, and shall doubtless say it again, that there are several Exceptions which should normally not be caught. They include ArithmeticException, SomethingOrOtherOutOfBoundsException, and NullPointerException.

In most instances all those ought to be removed by correcting the code.
The first place to look is the error stack, which gives you the location where the Exception occurs. In this case it would appear to be in your ToolBar0 class, line 165, in the doEditFind() method.

Go to that line and find every object in sight in that line. Check whether it has been initialised. Forgetting to initialise is the commonest cause of a NullPointerException. If you haven't worked it out soon, add a line one before it which reads something like:
You will get a printout which reads something like this:

Object1: Class1@20345fd Object2: Class2[String"Campbell", int 2, double 3.0, address"123High St,Ennytown."] Object3: null

If you find "null" written anywhere, eureka, you can find out where you forgot to initialise that object.

If that fails:
  • Look at every method which might return anything to line 165, see whether that could be null.
  • Repeat the procedure for the next line in the error message, line 265.

  • Once you have been programming for more than a few weeks, that sort of exception hunting will become seecond nature to you.

    CR
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!