Advertisement
NB52053

foo

Aug 23rd, 2017
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import javax.swing.*;
  6. class Apology extends JFrame {
  7.     public static void main(String[] args)
  8.     {
  9.         EventQueue.invokeLater(new Runnable() {
  10.             public void run() {
  11.                 new Apology();
  12.             }
  13.         });
  14.     }
  15.     public Apology() {
  16.         int strengthOfFeelings = 0;
  17.         boolean apologyAccepted = false;
  18.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  19.         String[] understandableResponses = new String[] {"Apology accepted", "Grovel some more"};
  20.         while (!apologyAccepted) {
  21.             StringBuffer apologyMessage = new StringBuffer("I'm ");
  22.             for (int i = 0; i < strengthOfFeelings; ++i) {
  23.                 apologyMessage.append("..so ");
  24.             }
  25.             apologyMessage.append("sorry.");
  26.             int result = JOptionPane.showOptionDialog(this, apologyMessage.toString(),
  27.                     "Accept the apology?", JOptionPane.YES_NO_OPTION,
  28.                     JOptionPane.QUESTION_MESSAGE, null,
  29.                     understandableResponses, understandableResponses[0]);
  30.             if (result == 0) {
  31.                 apologyAccepted = true;
  32.             }
  33.             else {
  34.                 ++strengthOfFeelings;
  35.             }
  36.         }
  37.         JOptionPane.showMessageDialog(this, "Dhonnobad! Iccha kore ragabo na! Ajke nijer dik ta beshi deksi!.", "inner dor!!",
  38.                 JOptionPane.PLAIN_MESSAGE);
  39.         dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement