Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How to Pass main(String args[]) args on execution to Swing component

  1. #1
    Junior Member dbliss3593's Avatar
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to Pass main(String args[]) args on execution to Swing component

    I wish to use args passed to main(String[]) during application execution to a Swing component.

    In a simple example, assume args passed are: a b c d

    And here is the result I look for:

    package argsinswing;
     
    import javax.swing.JOptionPane;
     
    public class ArgsInSwing {
     
        public static void main(String[] args) {
            String str1 = args[0];
            String str2 = args[1];
            String str3 = args[2];
            String str4 = args[3];
            JOptionPane.showMessageDialog(null, str1 + ", "+ str2 + ", "+ str3 + ", " str4, "Args are:" ,JOptionPane.PLAIN_MESSAGE);
        }
    }
    Attached Images Attached Images


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How to Pass main(String args[]) args on execution to Swing component

    Welcome to the forum! Thanks for taking the time to learn how to post code correctly. If you haven't already, please read this topic to learn other useful info for new members.

    There's something missing . . . You seem to be doing what you've described. What help do you need?

  3. #3
    Junior Member dbliss3593's Avatar
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to Pass main(String args[]) args on execution to Swing component

    Yes, it works! Please "park" this in the silly questions directory while I think of a better question to ask the community.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How to Pass main(String args[]) args on execution to Swing component

    We'll call it solved rather than silly.

Similar Threads

  1. Drawing a string without use of Main(String[] args)
    By JakkyD in forum AWT / Java Swing
    Replies: 4
    Last Post: December 17th, 2012, 11:14 PM
  2. Passing command line args from main to another class
    By csharp100 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 4th, 2012, 11:11 AM
  3. Not sure if run() or main(String[] args)
    By Brock Lee in forum What's Wrong With My Code?
    Replies: 6
    Last Post: May 25th, 2012, 12:19 PM
  4. Why main(String args[]) method needs to be public?
    By rohan22 in forum Java Theory & Questions
    Replies: 11
    Last Post: December 7th, 2011, 11:41 PM
  5. Java main method args
    By mattxo in forum Java Theory & Questions
    Replies: 3
    Last Post: May 16th, 2011, 09:45 AM