Re: Problem initializing objects in GUI

Phil Doble <[email protected]>
Newsgroups gmane.comp.java.netbeans.user-interface
Message-ID <[email protected]>
Two suggestions...

1. Create the object where it is declared - e.g.:
SomeClass anObject = new SomeClass();

2. If something more complicated is required, use "lazy initialisation"...
...
SomeClass anObject;
...
public void aMethod() {
   if (anObject == null) {
      anObject = new SomeClass();
      ...
   }
   ...
}



Trabajo wrote:
> 
> I made a program that I want to implement now in a GUI. I've built a GUI
> with the Netbeans GUI Editor. When a certain button is pressed, it must
> create an object. My GUI components are all correct and so is my program
> (no errors) but at runtime I get an exception:
> 
> "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
> 
> This is because I have trouble with the initialization of my objects that
> are not part of the UI. Where do I have to initialize my objects in order
> to use them properly?
> 

-- 
View this message in context: http://www.nabble.com/Problem-initializing-objects-in-GUI-tf3942794.html#a11210874
Sent from the Netbeans - UI mailing list archive at Nabble.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.