Link to home
Start Free TrialLog in
Avatar of eugene007
eugene007

asked on

deleting

In my HospitalGUI.java I have the foolowing code:

if(ae.getSource()==deleMF)
{
    //codes
}

The codes in the if clause is suppose to delete the Medical Facility along with its procedures.

I also have the functionality of saving and loading in my HospitalGUI.java.

It seems that when ever I load the patients and the medical facility and the procedures, and then I try to delete the medical facility I get errors.

However when I dont load the objects, but add the procedures and etc, and then try to delete the medical facility it works fine.

You can download the program from:

www.mutaiyas.com/db/GUI.zip

along with the download I have included a .txt file, which you would be able to load from the GUI.

How do I solve this problem?.

Your help is kindly appreciated.

Regards

Eugene
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

>>and then I try to delete the medical facility I get errors.

That's not helpful. Please say what errors and post the stack trace
Avatar of eugene007
eugene007

ASKER

java.lang.NullPointerException
        at HospitalGUI.actionPerformed(HospitalGUI.java:233)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
86)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1839)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:245)
        at java.awt.Component.processMouseEvent(Component.java:5100)
        at java.awt.Component.processEvent(Component.java:4897)
        at java.awt.Container.processEvent(Container.java:1569)
        at java.awt.Component.dispatchEventImpl(Component.java:3615)
        at java.awt.Container.dispatchEventImpl(Container.java:1627)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483
)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)

        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
        at java.awt.Container.dispatchEventImpl(Container.java:1613)
        at java.awt.Window.dispatchEventImpl(Window.java:1606)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:201)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if(p.getName().equalsIgnoreCase(mf.getName()))
{
     equality = true;
}
One of those objects (4 of them) is null
Actually it's 3 of them (read them left to right)
(Meaning that mf.getName() could return null without a problem) So it's one or more of the first three (although only one of them will have caused the exception to be thrown)
if(p!=null)
{                      
    if(p.getName().equalsIgnoreCase(mf.getName()))
    {
              equality = true;
    }
}

That solves the problem, as u have mentioned. I surely have to learn to trace the error, by looking at my console.      
Yep. You *have* learned already now ;-)
:-)
I better start sleeping early, and wake up early, before posting questions to EE.