public class InstallerFrame {
public Navigator getNavigator() { ... }
}
public interface Navigator
{
/**
* Returns the button to navigate to the next panel.
*
* @return the 'next' button
*/
JButton getNext();
/**
* Registers a listener that may veto navigation to the next panel.
*
* @param listener the listener. May be <tt>null</tt>
*/
void setNextListener(VetoableEventListener listener);
/**
* Returns the button to navigate to the previous panel.
*
* @return the 'previous' button
*/
JButton getPrevious();
/**
* Registers a listener that may veto navigation to the previous panel.
*
* @param listener the listener. May be <tt>null</tt>
*/
void setPreviousListener(VetoableEventListener listener);
/**
* Returns the button to quit installation.
*
* @return the 'quit' button
*/
JButton getQuit();
/**
* Registers a listener that may veto quitting installation.
*
* @param listener the listener. May be <tt>null</tt>
*/
void setQuitListener(VetoableEventListener listener);
/**
* Navigates to the next panel.
*
* @return <tt>true</tt> if the next panel was displayed, or <tt>false</tt> if the last panel is displayed or
* navigation is vetoed
*/
boolean next();
/**
* Navigates to the previous panel.
*
* @return <tt>true</tt> if the previous panel was displayed, or <tt>false</tt> if the first panel is displayed or
* navigation is vetoed
*/
boolean previous();
/**
* Quits installation.
*
* @return <tt>true</tt> if installation was quit, or <tt>false</tt> if quit failed was vetoed
*/
boolean quit();
}
public interface VetoableEventListener extends EventListener
{
/**
* Invoked to determine if an event should be vetoed.
*
* @param source the source that triggered the event
* @return <tt>true</tt> if the event should be vetoed, or <tt>false</tt> if it should proceed
*/
boolean veto(Object source);
}
Would an API like the following suffice?
You would have access to the 3 buttons, 'Next', 'Previous' and 'Quit' and be able to register a VetoableEventListener for each to veto the default behaviour of next(), previous() and quit().