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.


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

Results 1 to 2 of 2

Thread: Hello Family

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Thanked 0 Times in 0 Posts

    Default Hello Family

    Hey guys how are you all. I've created a program that displays my family's names in GUI. I decided now that i want to take it to the next level and have 2 command line arguments, the row and the column to display the names in a grid layout. I am not sure how to do this, i have converted the strings to Integers but don't know how to call them.

    import java.awt.Container;
    import java.awt.GridLayout;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    // Program to display a greeting to family members.
    public class HelloFamily extends JFrame
      // Constructor.
      public HelloFamily(noOfColumns, noOfRows)
        setTitle("Hello Family");
        Container contents = getContentPane();
        // Family names to appear in one line.
        contents.setLayout(new GridLayout(0, noOfColumns, 10, 20));
        contents.add(new JLabel("Hello Shyam!"));
        contents.add(new JLabel("Hello Devesh!"));
        contents.add(new JLabel("Hello Dinesh!"));
        contents.add(new JLabel("Hello Ramila!"));
        contents.add(new JLabel("Hello Suresh!"));
        contents.add(new JLabel("Hello Vijya!"));
        contents.add(new JLabel("Hello Shashi!"));
        contents.add(new JLabel("Hello Manju!"));
        contents.add(new JLabel("Hello Premji!"));
        contents.add(new JLabel("Hello Kanta!"));
        contents.add(new JLabel("Hello Ronak!"));
        contents.add(new JLabel("Hello Rohini!"));
        contents.add(new JLabel("Hello Palvi!"));
        contents.add(new JLabel("Hello Jahanvi!"));
      } // HelloFamily
      // Create a HelloFamily and make it appear on screen.
      public static void main(String [] args)
        int noOfColumns = Integer.parseInt(args[0]);
        int noOfRows = Integer.parseInt(args[1]);
        HelloFamily theHelloFamily = new HelloFamily();
      } // main
    } // class HelloFamily

    Any suggestions guys?

    I would really appreciate it!

    Kind regards


  2. #2
    Registered Users javapenguin's Avatar
    Join Date
    May 2010
    North Central Illinois
    My Mood
    Thanked 112 Times in 110 Posts

    Default Re: Hello Family

    HelloFamily theHelloFamily = new HelloFamily(noOfColumns, noOfRows);
    Please mark solved threads as "Solved" by going to threads and clicking "Mark Solved"
    Using code tags

    How To ask questions the smart way
    Java Tutorials
    Java API
    Save Our Snips
    Hit THANKS to thank a person. Hit REP+ to increase reputation (or decrease it). Cannot give to same person for a while.
    Shooting Park Road Baptist Church Site