Command line program that generates Dialog boxes


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Command line program that generates Dialog boxes

  1. #1
    Join Date
    Oct 2004
    Posts
    13

    Command line program that generates Dialog boxes

    PHP Code:
                int type Integer.getInteger(args[0]);
                
    String messageType "";
                switch (
    type)
                {
                        case 
    1messageType "PLAIN_MESSAGE";
                        case 
    2messageType "ERROR_MESSAGE";
                        case 
    3messageType "INFORMATION_MESSAGE";
                        case 
    4messageType "WARNING_MESSAGE";
                        case 
    5messageType "QUESTION_MESSAGE";
                }               
                
    JOptionPane.showMessageDialog(nulladdNewLines(args[1],
                        
    CHARS_PER_LINE), args[2], JOptionPane.messageType); 
    I'm trying to write a simple command line program that creates a dialog box based on the parameters I pass.

    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.

  2. #2
    Join Date
    May 2004
    Posts
    219

    Re: Command line program that generates Dialog boxes

    Originally posted by Valgarv
    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?
    getInteger returns an Integer object.
    parseInt returns a primitive 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)
    WARNING_MESSAGE, etc are constant ints defined within the JOptionPane class. They aren't strings at all. You should be doing
    Code:
    case 4: messageType = JOptionPane.WARNING_MESSAGE;
    instead of
    Code:
    case 4: messageType = "WARNING_MESSAGE";

  3. #3
    Join Date
    Oct 2004
    Posts
    13
    That worked great. Thanks for the clarification.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center