FileDocCategorySizeDatePackage
ModalYesNoDialog.javaAPI DocExample1190Sat Feb 22 16:39:48 GMT 1997None

ModalYesNoDialog

public class ModalYesNoDialog extends Dialog implements ActionListener

Fields Summary
private boolean
isYes
Constructors Summary
ModalYesNoDialog(Frame frame, String question)


	      
		super(frame, true /* modal */);
		Label label = new Label(question);
		label.setFont( new Font("Dialog",Font.PLAIN,20) );
		add( "Center", label );

		Panel yn = new Panel();
		Button button = new Button("Yes");
		button.addActionListener( this );
		yn.add( button );
		button = new Button("No");
		button.addActionListener( this );
		yn.add( button );
		add("South", yn);
		pack();
	
Methods Summary
public synchronized voidactionPerformed(java.awt.event.ActionEvent e)

		isYes = e.getActionCommand().equals("Yes");
		dispose();
	
public synchronized booleananswer()

		return isYes;
	
public static voidmain(java.lang.String[] s)

		Frame f = new Frame();
		f.add( "Center", new Label("I'm the application") );
		f.add( "South", new Button("Can you press me?") );
		f.pack();
		f.show();

		ModalYesNoDialog query = new ModalYesNoDialog( f, "Do you love me?");
		query.show();
		if ( query.answer() == true )
			System.out.println("She loves me...");
		else
			System.out.println("She loves me not...");