Hey, so I'm trying to make a text-based game using mostly Swing GUI; the code I have so far is below. When I use JOptionPanes I modify the icon, title, and suchlike on them, so I have about two lines of code for every JOptionPane. I created methods for them so I wouldn't have to retype the specs each time. The one for the MessageDialog works fine, but the InputDialog doesn't seem to recognize my String as a String; it gives an incompatible type error. It is reading my String as simply and Object and I don't know why. Any ideas?
import javax.swing.*;
import java.util.*;
public class Game2
{
public static Icon sword=new ImageIcon();
public static void message(String m) //using these methods because I have specs for each JOptionPane that I don't
{ //want to type every time I use one. This one works fine.
JOptionPane.showMessageDialog(null, m, "Game", JOptionPane.INFORMATION_MESSAGE, sword);
}
public static String input(String i) //this one, however, gives an "incompatible types" error
{
String userInput;
userInput=JOptionPane.showInputDialog(null, i, "Game", JOptionPane.INFORMATION_MESSAGE, sword, null, null);
return userInput;
}
public static void main(String[] args)
{
message("Hello! Welcome to my game!");
input("Please enter your name.");
}
}