I am having an issue within the parameters of my JOptionPane MessageDialog
. I am trying to print out the list of usernames that are in my array list, along with there corresponding time stamp for when they logged in.
Code:
Calendar currentDay = Calendar.getInstance();
loginArray.add(userName);
JOptionPane.showMessageDialog(null, loginArray.get(0), currentDay.getTimeInMillis());
Error:
gui.java:299: error: no suitable method found for showMessageDialog(<null>,String,long)
I understand what the error is saying, but I have tried to cast it to a String, etc and it won't allow me to... Should I try toString
?
Of course it doesn't, the Java Docs clearly state
showMessageDialog(
Component parentComponent,
Object message, String title,
int messageType)
And I don't know why you're trying to pass currentDay.getTimeInMillis
as the message parameter, the Java Docs state
messageType - the type of message to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
Some idea of what you are tying to achieve might help use to provide you with a solution
StackOverflow is not a replacement for the Java Docs or tutorials.