FileDocCategorySizeDatePackage
WizardDialog.javaAPI DocJMF 2.1.1e8592Mon May 12 12:20:32 BST 2003jmapps.ui

WizardDialog

public class WizardDialog extends JMDialog

Fields Summary
public static final String
ACTION_FINISH
public static final String
ACTION_CANCEL
public static final String
ACTION_NEXT
public static final String
ACTION_BACK
private String
strResultAction
private String
strImage
private JMPanel
panelPages
private Button
buttonBack
private Button
buttonNext
private Button
buttonFinish
private Button
buttonCancel
private Vector
vectorPages
private Panel
panelCurPage
private CardLayout
layoutCard
protected Frame
frameOwner
Constructors Summary
public WizardDialog(Frame frameOwner, String strTitle, boolean boolModal, String strImage)



                
    	this ( frameOwner, strTitle, boolModal, strImage, null );
    
public WizardDialog(Frame frameOwner, String strTitle, boolean boolModal, String strImage, Panel[] arrPages)

    	super ( frameOwner, strTitle, boolModal );

        this.frameOwner = frameOwner;
        this.strImage = strImage;
    	try {
    	    init ();
    	}
    	catch ( Exception exception ) {
    	    exception.printStackTrace ();
    	}
    	setPages ( arrPages );
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent event)

    	String		strCmd;

    	strCmd = event.getActionCommand ();
    	if ( strCmd.equals(ACTION_FINISH)  ||  strCmd.equals(ACTION_CANCEL) ) {
    	    if ( strCmd.equals(ACTION_FINISH) ) {
    	    	if ( onPageDone(panelCurPage) == false )
                    return;
    	    	if ( onFinish() == false ) {
                    setPage ( getFirstPage() );
                    return;
                }
    	    }
    	    strResultAction = strCmd;
    	    this.dispose ();
    	}
    	else if ( strCmd.equals(ACTION_BACK) ) {
    	    setPrevPage ();
    	}
    	else if ( strCmd.equals(ACTION_NEXT) ) {
    	    setNextPage ();
    	}
    
private java.awt.PanelcreatePanelButtons()

    	Panel	panel;
    	Panel	panelButtons;

    	panelButtons = new Panel ( new FlowLayout(FlowLayout.RIGHT) );

    	panel = new Panel ( new GridLayout(1,0,6,6) );
    	panelButtons.add ( panel );

    	buttonBack = new Button ( ACTION_BACK );
    	buttonBack.addActionListener ( this );
    	panel.add ( buttonBack );

    	buttonNext = new Button ( ACTION_NEXT );
    	buttonNext.addActionListener ( this );
    	panel.add ( buttonNext );

    	buttonFinish = new Button ( ACTION_FINISH );
    	buttonFinish.addActionListener ( this );
    	panel.add ( buttonFinish );

    	buttonCancel = new Button ( ACTION_CANCEL );
    	buttonCancel.addActionListener ( this );
    	panel.add ( buttonCancel );

    	return ( panelButtons );
    
public java.lang.StringgetAction()

    	return ( strResultAction );
    
public java.awt.PanelgetCurrentPage()

    	return ( panelCurPage );
    
protected java.awt.PanelgetFirstPage()

    	Panel	panelPage = null;

    	if ( vectorPages != null  &&  !vectorPages.isEmpty() ) {
    	    panelPage = (Panel) vectorPages.firstElement ();
    	}
    	return ( panelPage );
    
protected java.awt.PanelgetLastPage()

    	Panel	panelPage = null;

    	if ( vectorPages != null  &&  !vectorPages.isEmpty() ) {
    	    panelPage = (Panel) vectorPages.lastElement ();
    	}
    	return ( panelPage );
    
protected java.awt.PanelgetNextPage(java.awt.Panel panelPage)

    	int		nIndex;
    	Panel	panelPageNext = null;

    	if ( panelPage == null ) {
    	    panelPageNext = getFirstPage ();
    	}
    	else if ( vectorPages != null  &&  !vectorPages.isEmpty() ) {
    	    nIndex = vectorPages.indexOf ( panelPage );
    	    if ( nIndex >= 0  &&  nIndex < vectorPages.size() - 1 )
    	    	panelPageNext = (Panel) vectorPages.elementAt ( nIndex + 1 );
    	}
    	return ( panelPageNext );
    
protected java.awt.PanelgetPrevPage(java.awt.Panel panelPage)

    	int		nIndex;
    	Panel	panelPagePrev = null;

    	if ( panelPage == null ) {
    	    panelPagePrev = getLastPage ();
    	}
    	else if ( vectorPages != null  &&  !vectorPages.isEmpty() ) {
    	    nIndex = vectorPages.indexOf ( panelPage );
    	    if ( nIndex > 0  &&  nIndex < vectorPages.size() )
    	    	panelPagePrev = (Panel) vectorPages.elementAt ( nIndex - 1 );
    	}
    	return ( panelPagePrev );
    
protected voidinit()

    	Panel		panel;
    	Panel		panelContent;
        ImageArea       imageArea;
        Image           image;

        this.setBackground ( Color.lightGray );
    	this.setLayout ( new BorderLayout(6,6) );
        this.setResizable ( false );
//    	this.addWindowListener ( this );

    	panelContent = new Panel ( new BorderLayout(6,6) );
        panelContent.setBackground ( Color.lightGray );
    	this.add ( panelContent, BorderLayout.CENTER );

        if ( strImage != null ) {
            panel = new Panel ( new BorderLayout() );
    	    panelContent.add ( panel, BorderLayout.WEST );

            image = ImageArea.loadImage ( strImage, this, true );
            imageArea = new ImageArea ( image );
            imageArea.setInsets ( 12, 12, 12, 12 );
    	    panel.add ( imageArea, BorderLayout.NORTH );
        }

    	layoutCard = new CardLayout ( 6, 6 );
    	panelPages = new JMPanel ( layoutCard );
        panelPages.setEmptyBorder ( 6, 6, 6, 6 );
    	panelContent.add ( panelPages, BorderLayout.CENTER );

    	panel = createPanelButtons ();
    	panelContent.add ( panel, BorderLayout.SOUTH );
    
protected booleanisFirstPage(java.awt.Panel panelPage)

    	boolean		boolResult;

    	boolResult = (panelPage == getFirstPage());
    	return ( boolResult );
    
protected booleanisLastPage(java.awt.Panel panelPage)

    	boolean		boolResult;

    	boolResult = (panelPage == getLastPage());
    	return ( boolResult );
    
protected booleanonFinish()

        return ( true );
    
protected booleanonPageActivate(java.awt.Panel panelPage)

        return ( true );
    
protected booleanonPageDone(java.awt.Panel panelPage)

        return ( true );
    
protected voidsetNextPage()

    	Panel	panelPage;

    	if ( panelCurPage != null  &&  onPageDone(panelCurPage) == false )
            return;
    	panelPage = getNextPage ( panelCurPage );
    	setPage ( panelPage );
    
private voidsetPage(java.awt.Panel panelPage)

    	if ( panelPage == null )
    	    return;

    	panelCurPage = panelPage;
    	onPageActivate ( panelCurPage );

    	panelPages.add ( panelCurPage, panelCurPage.getName() );
    	layoutCard.show ( panelPages, panelCurPage.getName() );

    	if ( isFirstPage(panelCurPage) ) {
    	    buttonBack.setEnabled ( false );
    	    if ( getFocusOwner() == buttonBack )
    	    	buttonNext.requestFocus ();
    	}
    	else {
    	    buttonBack.setEnabled ( true );
    	}

    	if ( isLastPage(panelCurPage) ) {
    	    buttonNext.setEnabled ( false );
            buttonFinish.setEnabled ( true );
    	    if ( getFocusOwner() == buttonNext )
    	    	buttonFinish.requestFocus ();
    	}
    	else {
    	    buttonNext.setEnabled ( true );
            buttonFinish.setEnabled ( false );
    	}

    	this.validate ();
    	panelCurPage.validate ();
    
public voidsetPages(java.awt.Panel[] arrPages)

    	int		i;
    	int		nCount;

    	if ( arrPages != null ) {
    	    panelCurPage = null;
    	    nCount = arrPages.length;
    	    vectorPages = new Vector ();
    	    for ( i = 0;  i < nCount;  i++ )
    	    	vectorPages.addElement ( arrPages[i] );
    	}

    	setNextPage ();
    
protected voidsetPrevPage()

    	Panel	panelPage;

    	panelPage = getPrevPage ( panelCurPage );
    	setPage ( panelPage );
    
public voidwindowActivated(java.awt.event.WindowEvent event)

    
public voidwindowClosed(java.awt.event.WindowEvent event)

    
public voidwindowClosing(java.awt.event.WindowEvent event)

    	this.dispose ();
    
public voidwindowDeactivated(java.awt.event.WindowEvent event)

    
public voidwindowDeiconified(java.awt.event.WindowEvent event)

    
public voidwindowIconified(java.awt.event.WindowEvent event)

    
public voidwindowOpened(java.awt.event.WindowEvent event)