/home/wpollock1/public_html/Java/Popup.java
// This program creates a blank pop-up window inside a Frame.
// The pop-up window appears and disappears when the user clicks
// the mouse in the main window ("myFrame", not "myWin").
// Written 1999 by Wayne Pollock, Tampa FL USA.
import java.awt.*;
import java.awt.event.*;
public class Popup
{ static Window myWin;
public static void main ( String [] args )
{ Frame myFrame = new Frame( "Wonder Window!" );
myFrame.setSize( 350, 200 );
myFrame.setBackground( Color.CYAN );
myFrame.setVisible( true );
myWin = new Window( myFrame ); // A pop-up window
// setBounds() is equal to setSize() and setLocation():
myWin.setBounds( 30, 30, 100, 100 );
myWin.setBackground( Color.BLUE );
myWin.setVisible( true );
myFrame.addWindowListener( new WindowAdapter()
{ public void windowClosing ( WindowEvent we )
{ System.exit( 0 );
}
}
);
myFrame.addMouseListener( new MouseAdapter ()
{ public void mouseClicked ( MouseEvent e )
{ myWin.setVisible( ! myWin.isVisible() );
}
}
);
}
}