I'm trying to write a simple command line program that creates a dialog box based on the parameters I pass.PHP Code:int type = Integer.getInteger(args[0]);
String messageType = "";
switch (type)
{
case 1: messageType = "PLAIN_MESSAGE";
case 2: messageType = "ERROR_MESSAGE";
case 3: messageType = "INFORMATION_MESSAGE";
case 4: messageType = "WARNING_MESSAGE";
case 5: messageType = "QUESTION_MESSAGE";
}
JOptionPane.showMessageDialog(null, addNewLines(args[1],
CHARS_PER_LINE), args[2], JOptionPane.messageType);
Ran as: java dialogProgram 3 "My Message" "The Title"
This program should create an Information Dialog titled "The Title" with the message "My Message"
The problems I am having are
1) int type = Integer.getInteger(args[0]); gives the error "Type mismatch: cannot convert from type Integer to int" - Is this not how you convert a String to an int?
2) My switch statement defines the message type based on the value of the first parameter. How do I concatenate JOptionPane. with my String variable messageType? (It doesn't accept Strings)
Any help would be appreciated.


Reply With Quote


Bookmarks