Hi,
This is my final question on my GUI , I promise.
I wanted to create a global String array that once it was initialized and set in one GUI that it could be accessed by any of the other related GUIs or do I have to pass it from from GUI to GUI, which I'm also not to sure of.

I've checked a few sites but 1 site seems to contradict the other.
Any help would be great.

Thanks,
Sean

Are all the GUIs part of the same application? Or are their going to be mulitiple instances of different java instances started?

Not sure..
The GUIs call each other but they appear as seperate frames on the screen but that doesnt matter so much as its just a demo and theyre the same size so it seems like they replace each other. All the GUIs are in the same folder.

Its a Taxi service UI and I want to be able to put the taxi order info. into an array and then use that array for when they go onto the "view order" page.

Not sure if any of that answers anything

Ok. There is a long explanation here, but unless you want it i'm not going to go into it.

The following should work for you though.

public class DomainModel
{
  // Your array object...
  Object aObjectArry = null;  // I'm not sure what this should be and just doing a filler object.

  // Static Singlton instance of DomainModel.
  private static DomainModel aDomainModel = null;

  // Notice a private constructor.
  private DomainModel()
  {

  }

  public static DomainModel getInstance()
  {
    if(aDomainModel == null)
    {
      aDomainModel = new DomainModel();
    }
    return aDomainModel;
  }

  public void setTaxData(Object [] objectArray)
  {
    aObjectArray = objectArray;
  }

  public Object[] getTaxData()
  {
    return aObjectArray;
  }
}

The domain model is a singlton. Which mean that there can only be one instance of the object in your application. The getInstance() method allows any other object to get that instance and then work with it. So kind of like a global, but different. Now, please be careful with singltons. They are the most over used design pattern and can really cause poor OO programming if over used.

This article has been dead for over six months. Start a new discussion instead.