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: problem in Grid Layout Program

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Unhappy problem in Grid Layout Program


    import javax.swing.*;
    import java.awt.*;

    public class GridLayoutDemo
    {
    private JFrame f;
    private JButton b1,b2,b3,b4,b5;

    public GridLayoutDemo()
    {
    f=new JFrame("grid window");
    b1=new JButton("button1");
    b2=new JButton("button2");
    b3=new JButton("button3");
    b4=new JButton("button4");
    b5=new JButton("button5");
    }

    public void LaunchFrame()
    {
    f.setLayout(new GridLayout(3,2));
    f.add(b1);
    f.add(b2);
    f.add(b3);
    f.add(b4);
    f.add(b5);

    f.pack();
    f.setSize(400,100);
    f.setVisible(true);
    }

    public static void main(String a[])
    {
    GridLayoutDemo gd=new GridLayoutDemo

    ();
    gd.LaunchFrame();
    }
    }
    this is my program for grid layout Demo da program is getting complied but its not getting executedgrid.PNG
    this is the error m getting


  2. #2
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default Re: problem in Grid Layout Program

    is your java file called GridLayoutDemo.java?

  3. #3
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: problem in Grid Layout Program

    You shouldn't write "java blahblahblah.java", just "java blahblahblahblah". Also, be aware of the classpath. In this case, you're not likely to be in trouble because of it, but in case of 3rd part libraries or with packages - well, this might be the case.
    Also, a very nice thing is that you don't try to work in IDE and use just a command line - you'll learn MUCH faster. Though MUCH more painful =)

  4. The Following User Says Thank You to angstrem For This Useful Post:

    siddessh_java (July 8th, 2013)

  5. #4
    Junior Member
    Join Date
    Jul 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: problem in Grid Layout Program

    Quote Originally Posted by derekxec View Post
    is your java file called GridLayoutDemo.java?
    yaa it is...

    --- Update ---

    thnx my program got executed........

Similar Threads

  1. [SOLVED] JPanel inside CENTER of BorderLayout is given GRID LAYOUT
    By JonLane in forum AWT / Java Swing
    Replies: 9
    Last Post: February 25th, 2012, 12:20 PM
  2. Program layout examples please
    By derekxec in forum Java Theory & Questions
    Replies: 1
    Last Post: July 2nd, 2011, 11:05 AM
  3. Replies: 1
    Last Post: April 14th, 2011, 07:50 AM
  4. Grid bag layout inside grid bag layout
    By kiddkoder in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 29th, 2011, 08:07 AM
  5. How to align the items in a form (grid layout)?
    By onlybarca in forum AWT / Java Swing
    Replies: 4
    Last Post: November 27th, 2010, 11:38 PM