Hello,

I have what is probably an obvious question.

I have a basic GUI, one is bsaically no more than a menu in its own class along with a bunch of support classes to do what i want. Another GUI which is for editing the information whcih the main GUI stores and processes.

I have an option to "add item" in the menu gui, this then opens the other GUI and you enter all the data you want, then hit "add".

so my question is, once the user hits "add" how do i then return the data they've input to the original GUI?

for example, the original GUI has something like;

ArrayList<data> info = new ArrayList<data>();

private AbstractAction getData(){
     pd = new GUIProcessData();

     pd.pack();
     pd.setLocationRelativeTo(null);
     pd.setVisible(true);

     info.add( ** the data from the other GUI once the add button is pressed ** );
}

It's not a real code snippet, but it's more just a better way to explain what i was hoping to achieve. I will post more code if it will help, but i'd love to get a clear explanation in words so i can attempt to do it myself.

Thanks in advance for any and all help. As i said, im sure its obvious, i've been working on something for most of the day to no avail.

  • xyster

Edited 3 Years Ago by Dani: Formatting fixed

Are you allowed to change the constructor signature in the second GUI? If so, probably the easiest way to achieve what you are after is to pass a reference for the original GUI in the second GUI's constructor and use that reference in the second GUI's addClick() method to callback to the original GUI.

For example, in the "original GUI":

ArrayList<data> info = new ArrayList<data>();

private void getData(){
pd = new GUIProcessData(this);

pd.pack();
pd.setLocationRelativeTo(null);
pd.setVisible(true);
}

public void addData(data someData)
{
 info.add(someData);
}

and in the second GUI:

OriginalGUI parent;

public GUIProcessData(OriginalGUI aParent)
{
 this.parent = aParent;
}

public void addButtonClicked()
{
  data someData = getCurrentData();
  parent.addData(someData);
}

public data getCurrentData()
{
  // method to retrieve the data settings in the second GUI
}

or something like that.

Thankyou so much for the quick reply. It was exactly what i needed, thank you so much. (the whole parent thing, didnt know i could do that so easily. lol).

Thank you once again. I'll make this as solved, if i can work out how to :D

This question has already been answered. Start a new discussion instead.