My suggestion is to make a simple MVC.
I am not sure I understand you.
The controllers will implement the two buttons action. You should store the String in your Model or whatever when Button 1 action is performed and you should get the stored String when Button 2 action performed.
Example code:
public class Controller {
private View view;
private Model model;
//constructor will get the view and the model, and adds ActionHandlers
public Controller(final Model amodel, final View aview) {
this.view=aview;
this.model=amodel;
addOneButtonActionHandler();
addSecondButtonActionHandler();
}
public void addOneButtonActionHandler(){
ActionListener actionHandler= new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
//some action to get the String from user (?)
model.storeItem(string);
}
};
view.addActionToOneButton(actionHandler);
}
public void addSecondButtonActionHandler(){
ActionListener actionHandler= new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
//some action to get the stored String from Model
//String key =model.getStoredItem();
}
};
view.addActionToSecondButton(actionHandler);
}
}