tags:

views:

233

answers:

1

This question is not so much a "How to create a gui", but more of a "where to create the gui".

I have some java code that checks to make sure the drivers needed are in place:

public boolean confirmDrivers() { 
       /* some logic */ 
       return someDriver.exists();
}

it gets called as:

if (confirmDrivers()) {
       createGUI();              
}

Is it a bad idea to have the actionlisteners defined for some buttons in createGUI() ? it seems out of place because that function is mostly just assignment (ie - myButton.setToolTipText("hay guyz click here!"); ), and the listeners contains minor logic (mostly to call other functions that DO contain the logic.

Just curious as to what others do in this situation.

+1  A: 

Split the GUI out from the business logic altogether. Wrap up the GUI as it's own class and attach the actionlisteners in the constructor, and maybe pass in whatever handles the actual business logic. Something like this:

if (confirmDrivers()) {
    new GUI(someBusinessLogicController);
}
Pesto