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: Help with Group Layout

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with Group Layout

    I am trying to create a group layout that looks like this:

    JLabel JTextField
    JLabel JComboBox

    For some reason when I run it, they are all on one line..

     
        JLabel depthLabel = new JLabel("Recursive Depth: ");
        JTextField depthText = new JTextField(2);
        JLabel color1Label = new JLabel ("Color 1: ");
     
        String[] colors = { "Blue", "Cyan", "Dark Gray", "Gray", "Green" };
        JComboBox color1 = new JComboBox(colors);
     
     
        buttonLayout.setAutoCreateGaps(true);
        buttonLayout.setAutoCreateContainerGaps(true);
     
        GroupLayout.SequentialGroup hSeqGroup = buttonLayout.createSequentialGroup();
        GroupLayout.SequentialGroup vSeqGroup = buttonLayout.createSequentialGroup();
     
        GroupLayout.ParallelGroup hParGroup1 = buttonLayout.createParallelGroup();
        GroupLayout.ParallelGroup hParGroup2 = buttonLayout.createParallelGroup();
     
        hParGroup1.addComponent(depthLabel);
        hParGroup2.addComponent(depthText);
     
        hParGroup1.addComponent(color1Label);
        hParGroup2.addComponent(color1);
     
        hSeqGroup.addGroup(hParGroup1);
        hSeqGroup.addGroup(hParGroup2);
     
        GroupLayout.ParallelGroup vParGroup = buttonLayout.createParallelGroup();
        GroupLayout.ParallelGroup vParGroup2 = buttonLayout.createParallelGroup();
     
        vParGroup.addComponent(depthLabel);
        vParGroup.addComponent(depthText);
     
        vParGroup2.addComponent(color1Label);
        vParGroup2.addComponent(color1);
     
        vSeqGroup.addGroup(vParGroup);
        vSeqGroup.addGroup(vParGroup2);
     
        buttonLayout.setHorizontalGroup(hSeqGroup);
        buttonLayout.setVerticalGroup(vSeqGroup);


  2. #2
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Default Re: Help with Group Layout

    You seem to be using an awful lot of code to get a 2x2 grid... I'd take a look at GridLayout.
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.

Similar Threads

  1. A JAVA Group
    By spect4cle in forum The Cafe
    Replies: 0
    Last Post: November 5th, 2011, 08:48 AM
  2. Replies: 1
    Last Post: April 14th, 2011, 07:50 AM
  3. learning group
    By cooler4hell in forum The Cafe
    Replies: 6
    Last Post: January 27th, 2011, 05:02 AM
  4. Facebook Group Moderator
    By JavaPF in forum Forum Updates & Feedback
    Replies: 1
    Last Post: October 5th, 2010, 09:09 AM