Howdy ranchers! I'm sorry I've posted a similar question before that you all helped me with, but I still haven't been able to completely figure it out. My assignment was to create a simple form that demonstrates the use of the factory and singleton design patterns. "Use the Factory pattern to ensure that each form input consists of a text label and a text field. Use the Singleton pattern for the submit button."
My current issue is I'm getting a NullPointerException when it's calling the add() methods in the JavaForm.java. Any hints, advice or help on what I can do or try to get this working would be much appreciated.
Here's my code:
Name.java file (I have similar Address.java, city.java, state.java, zip.java, phone.java files I won't post here)
If you observe the code snippets in your last post carefully, you would realize that your design and implementation are not mapping correctly to logical reasoning...
Your JavaForm1 is a JFrame which can have components added to it...
In the JavaForm1 constructor you are first setting up the title, size, exit-operation, and layout for the frame... Next you are created a local reference to an object of type Form and calling a method on this local reference then construction of the JavaForm1 is completed... You have not yet added a single component to it therefore the frame only has a title with its set size, exit-operation and layout property, hence its a completely astonishing 850x200 blank frame...
posted 5 years ago
So doesn't the local reference to the Form object build and add to my JFrame?