Hi all,

building my homework work fine but when running the program I get the
following errors:

run:
Exception in thread "main" java.lang.NullPointerException
        at MyOwnEvent.getCurrentTime(MyOwnEvent.java:20)
        at MyOwnListenerImpl.somethingHappened(MyOwnListenerImpl.java:
4)
        at MyOwnEventSource.triggerSomethingEvent
(MyOwnEventSource.java:31)
        at MyOwnEventExample.main(MyOwnEventExample.java:12)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


I´ m a little bit confused about how to return the date and time. I
think there lies the root problem that leads to these errrors. Here´s
a glance at my "MyOwnEvent.java":

[...]

import java.util.EventObject;
import java.util.Date;

public class MyOwnEvent extends EventObject {

    /** Creates a new instance of MyEvent */
    public MyOwnEvent(Object source) {
        super(source);
    }

    public MyOwnEvent(Object source, String myOwnEventName) {
        super(source);
        this.myOwnEventName = myOwnEventName;
    }

    private String myOwnEventName;
    private Date myOwnEventDate;

    public long getCurrentTime() {
        return myOwnEventDate.getTime();
    }

   // public void setMyOwnEventDate(Date myOwnEventDate) {
   //     this.myOwnEventDate = myOwnEventDate;
   // }

}

I always get in trouble with the myOwnEventDate variable. Does it
really have to by a Date ? When using the myOwnEventDate within
getCurrentTime it´s only possible to use "getTime". That´s why I
declared the returning value of getCurrentTime as "long". Something´s
wrong there but I just can´t clear the fog.

Any help would be appreciated :)

Kind regards

Frank

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to