0

I'm getting this error message:

The method showMessageDialog(Component, Object, String, int, Icon) in the type 
   JOptionPane is not applicable for the arguments (JFrame, String, String, int, int, ImageIcon, String) 

When I hover over JOptionPane.showMessageDialog. I followed the java tutorial and don't know what the problem is. Any idea?

Java tutorial: http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html#button

String option = "Restart";
JFrame frame = new JFrame();
ImageIcon ic = new ImageIcon("hangmanIcon.png");
JOptionPane.showMessageDialog(frame,
        "He's dead, game over. The word was " + wordList[level],
        "You Lost",
        JOptionPane.OK_OPTION,
        JOptionPane.INFORMATION_MESSAGE,
        ic,
        option);
Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Anon
  • 141
  • 1
  • 11

1 Answers1

4

The Java API for JOptionPane will tell you what method signatures are available/allowed, and that method signature isn't one. You probably want to use this one instead:

public static void showMessageDialog(Component parentComponent,
                 Object message,
                 String title,
                 int messageType,
                 Icon icon)
                          throws HeadlessException

Edit

Perhaps what you want to use instead is not the showMessageDialog but rather the showOptionDialog which does allow for more parameters.

String[] options = {"Restart", "Exit"};
String option = options[0];
JFrame frame = new JFrame();
ImageIcon ic = new ImageIcon("hangmanIcon.png");
JOptionPane.showMessageDialog(frame,
        "He's dead, game over. The word was " + wordList[level],
        "You Lost",
        JOptionPane.OK_OPTION,
        JOptionPane.INFORMATION_MESSAGE,
        ic,
        options,
        option);
Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373