Search code examples
javadialogjoptionpane

Novice Java Student: How can I create a series of output dialog boxes using JOptionpane?


From 1925 through 1963, Burma Shave advertising signs appeared next to high- ways all across the United States. There were always four or five signs in a row containing pieces of a rhyme, followed by a final sign that read “Burma Shave.” For example, one set of signs that has been preserved by the Smithsonian Institution reads as follows:

Shaving brushes You'll soon see 'em On a shelf In some museum Burma Shave

Find a classic Burma Shave rhyme on the Web. Write, compile, and test a class that produces a series of four dialog boxes so that each displays one line of a Burma Shave slogan in turn. Save the class as BurmaShave.java.


Solution

  • You'll want to start by looking at the documentation for JOptionPane, specifically JOptionPane.showMessageDialog.

    Sample usage from the javadoc:

    JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE); 
    

    Just write your main method do do this several (ie: four, according to your question) times in a row, replacing the strings "alert" with whatever messages you want.