Hi,
I need to create a simple Java application for my coursework, and i'm having a little trouble.
Basically, i've created a class that deals with all the GUI stuff. And part of the GUI requires a popup dialogue window, that allows for the creation of a new entry.
I don't want to deal with any of the database stuff in the GUI class, so I want the function to return the data that was inputted in the dialogue box when you press OK.
Here is a bit of the code I wrote...
code:
public Contact addContactWindow() {
//opens an add contact dialouge box, returns a Contact object
//SNIP
{ //listener for the ok button
class MenuItemListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
//code goes here
}
}
ActionListener listener = new MenuItemListener();
okButton.addActionListener(listener);
}
}
So when the ok button is pressed, the code in the actionPerformed function will be executed. I can construct a Contact object easily, however I can't figure out how to return it.