View Single Post
  #1 (permalink)  
Old 07-31-2007, 06:25 AM
carl carl is offline
Member
 
Join Date: Jul 2007
Posts: 35
carl is on a distinguished road
Java constructor method
Hi, So I got a Java constructor question...suppose I am creating a GUI through a constructor like so:
Code:
public EmailFrame() { // SETS UP THE UI HERE }
Now I am required to create a similar GUI but with certain fields different...like the window title of the frame for example and so I create a constructor like so:
Code:
public EmailFrame(String windowTitle) { // SETS UP THE UI HERE + THE CODE FOR THE TITLE
So now we have a bad programming situation here. I have a default constructor that does not take any arguments but the code is similar to the other constructor that does take an argument and everything is the exact same other than the one line that deals with the window title.

How do I go about so that I don't have to re-call the code of the first constructor with minimal work? I have some ideas but before I try I would like to receive some feedback.
Thanks.
Reply With Quote
Sponsored Links