Java Code

import java.awt.*;
import javax.swing.*;
public class JOptionsEx extends JApplet
{
	JOptionPane optionPane;
	public void init( )
	{
		// yes no 
		int userPick = JOptionPane.showConfirmDialog( null,
			    "Would you like to save your data?\n"
			    + "Saving is permanent!",
			    "Title goes here",
			    JOptionPane.YES_NO_OPTION);
		if ( userPick == JOptionPane.YES_OPTION )
			System.out.println( "yes!" );
		else if ( userPick == JOptionPane.NO_OPTION )
			System.out.println( "no!" );
		
		// yes no cancel
		userPick = JOptionPane.showConfirmDialog( null,
			    "Would you like to save your data?\n"
			    + "Saving is permanent!",
			    "Title goes here",
			    JOptionPane.YES_NO_CANCEL_OPTION);
		if ( userPick == JOptionPane.YES_OPTION )
			System.out.println( "yes!" );
		else if ( userPick == JOptionPane.NO_OPTION )
			System.out.println( "no!" );
		else if ( userPick == JOptionPane.CANCEL_OPTION )
			System.out.println( "cancel" );
		
		// ok cancel
		userPick = JOptionPane.showConfirmDialog( null,
			    "Would you like to save your data?\n"
			    + "Saving is permanent!",
			    "Title goes here",
			    JOptionPane.OK_CANCEL_OPTION);
		if ( userPick == JOptionPane.OK_OPTION )
			System.out.println( "OK!" );
		else if ( userPick == JOptionPane.CANCEL_OPTION )
			System.out.println( "cancel" );
	}
}

©2007- by E.S.Boese. All Rights Reserved