FileDocCategorySizeDatePackage
JMDialog.javaAPI DocJMF 2.1.1e4775Mon May 12 12:20:30 BST 2003jmapps.ui

JMDialog

public class JMDialog extends Dialog implements WindowListener, ActionListener

Fields Summary
public static final String
ACTION_OK
public static final String
ACTION_CANCEL
public static final String
ACTION_CLOSE
public static final String
ACTION_OPEN
public static final String
ACTION_SAVE
public static final String
ACTION_YES
public static final String
ACTION_NO
protected Frame
frameOwner
private String
strAction
private boolean
boolFirstTimeVisible
Constructors Summary
public JMDialog(Frame frame, String strTitle, boolean boolModal)



              
        super ( frame, strTitle, boolModal );

        frameOwner = frame;
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent event)

    
public voidaddNotify()

	    this.setBackground ( Color.lightGray );
        this.addWindowListener ( this );

        super.addNotify ();
        autoPosition ();
    
public voidautoPosition()

        Dimension       dim;
        Dimension       dimFrame;
        Dimension       dimDialog;
        Dimension       dimScreen;
        Point           point;
        Insets          insets;

        if ( frameOwner != null  &&  frameOwner.isShowing() ) {
            point = frameOwner.getLocationOnScreen ();
            if ( this.isModal() ) {
                insets = frameOwner.getInsets ();
                point.x += insets.left;
                point.y += insets.top;
            }
            else {
                dimFrame = frameOwner.getSize ();
                point.y += dimFrame.height;
            }
            dim = this.getPreferredSize ();
            dimDialog = this.getSize ();
            dimDialog.width = Math.max ( dim.width, dimDialog.width );
            dimDialog.height = Math.max ( dim.height, dimDialog.height );
            dimScreen = Toolkit.getDefaultToolkit().getScreenSize();
            if ( point.x + dimDialog.width > dimScreen.width )
                point.x = dimScreen.width - dimDialog.width;
            if ( point.y + dimDialog.height > dimScreen.height )
                point.y = dimScreen.height - dimDialog.height;
            this.setLocation ( point );
        }
        else {
            setLocationCenter ();
        }
    
protected jmapps.ui.JMPanelcreateButtonPanel(java.lang.String[] arrActions)

        int         i;
        int         nCount;
        JMPanel     panelButtons;
        Button      button;

        panelButtons = new JMPanel ( new GridLayout(1,0,12,6) );
        nCount = arrActions.length;
        for ( i = 0;  i < nCount;  i++ ) {
            button = new Button ( arrActions[i] );
            button.addActionListener ( this );
            panelButtons.add ( button );
        }
        return ( panelButtons );
    
public java.lang.StringgetAction()

        return ( strAction );
    
protected java.awt.FramegetOwnerFrame()

        return ( frameOwner );
    
protected voidsetAction(java.lang.String strAction)

        this.strAction = strAction;
    
public voidsetLocationCenter()

        Dimension       dimDialog;
        Dimension       dimScreen;
        Point           point;

        dimDialog = this.getSize ();
        dimScreen = Toolkit.getDefaultToolkit().getScreenSize();
        point = new Point ( (dimScreen.width - dimDialog.width) / 2,
                                (dimScreen.height - dimDialog.height) / 2 );
        this.setLocation ( point );
    
public voidsetVisible(boolean boolVisible)


        if ( boolVisible == true  &&  !this.isVisible()  &&  boolFirstTimeVisible == true ) {
            boolFirstTimeVisible = false;
            autoPosition ();
        }
        super.setVisible ( boolVisible );
    
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)