Dialogs.java

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Dialogs implements ActionListener
{
   JButton go = new JButton("Go");
   JLabel label = new JLabel("");
   NTJFrame frame = new NTJFrame("Dialog");
   
   public Dialogs() 
   {  
      String inputValue = JOptionPane.showInputDialog("Please enter a value");
      int n = Integer.parseInt(inputValue);
      label.setText("n = " + n);
      frame.getContentPane().add(go);
      frame.getContentPane().add(label, "North");
      go.addActionListener(this);
      frame.setVisible(true);
   }
   
   public static void main(String[] args)
   {
      new Dialogs();
   }
   
   public void actionPerformed(ActionEvent e)
   {
      Object[] options = {"Win", // button labels
                          "Place",
                          "Show"};
      int n = JOptionPane.showOptionDialog(frame,
               "How do you want to Bet", // question
               "Bet", // window title
               JOptionPane.YES_NO_CANCEL_OPTION,
               JOptionPane.QUESTION_MESSAGE,
               null,
               options,
               options[2]);
    
      if (n == 0)
         label.setText("win");
      else if (n == 1)
         label.setText("place");
      else 
         label.setText("show");
    }
}