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 2 of 2

Thread: Hello Family

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    15
    Thanks
    0
    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!"));
     
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        pack();
      } // 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();
     
        HelloFamily theHelloFamily = new HelloFamily();
        theHelloFamily.setVisible(true);
      } // main
    } // class HelloFamily

    Any suggestions guys?

    I would really appreciate it!

    Kind regards

    Shyam


  2. #2
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Hello Family

    HelloFamily theHelloFamily = new HelloFamily(noOfColumns, noOfRows);