Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting 4 columns for 3 more buttons.

Posted on 2004-03-31
3
Medium Priority
?
230 Views
Last Modified: 2010-03-31
I was able to get 4 rows with the buttoms but for some reason I can't get 4 columns for 3 more buttons.


final JLabel l1 = new JLabel();
        l1.setBorder(BorderFactory.createLineBorder(Color.yellow));

        p1.setBorder(BorderFactory.createLoweredBevelBorder());
        p4.setBorder(BorderFactory.createLoweredBevelBorder());
        p4.setBackground(Color.blue);
       
        p1.setLayout(new BorderLayout());
        add(p1, BorderLayout.EAST);
        p1.add(p2);
        p1.setLayout(new GridLayout(1,2));
        p1.add(p2);
        p1.add(p3, BorderLayout.CENTER);

        p2.setLayout(new GridLayout(1,1));
        p2.add(p4);

        p4.setLayout(new BorderLayout());
        add(p4, BorderLayout.CENTER);
        p4.setLayout(new GridLayout(3,3));
        p4.add(b1); p4.add(b2); p4.add(b3);
        p4.add(b4); p4.add(l1); p4.add(b5);
        p4.add(b6); p4.add(b7); p4.add(b8);
       
        p5.setLayout(new GridLayout(5,1));
        p5.add(new JLabel("Name 1\n"));
        p5.add(new JLabel("Name 2"));
        p5.add(new JLabel("Name 3"));
        p5.add(new JLabel("Name 4"));
        p5.add(new JLabel("Name 5"));
       
       
        p3.setLayout(new GridLayout(1,3));
        p3.add(new JPanel()); p3.add(p5);
        p3.add(new JPanel());

       
0
Comment
Question by:Drop_of_Rain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 300 total points
ID: 10727992
>  p4.setLayout(new GridLayout(3,3));

 p4.setLayout(new GridLayout(3,4));
0
 

Author Comment

by:Drop_of_Rain
ID: 10728053
I had tried that I could see the row when I added a row, I thought that I would see the column as well. I added more buttons and there it was.
0
 
LVL 92

Expert Comment

by:objects
ID: 10728069
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question