0

I have a specific grid i want to make but im not sure how to make it

-------------------------------------------
|                                         |
|                                         | <-- My Banner
|                                         |
-------------------------------------------
|                      |                  |
|      Panel1          |                  |
|                      |                  |
-----------------------|                  |
|                      |                  |
|      Panel2          |                  | <--Info or something. I want this space to be
|                      |                  |    a white area. Im going to put images here.
-----------------------|                  |
|                      |                  |
|      Panel3          |                  |
|                      |                  |
-------------------------------------------

So im wondering what layout manager should i use?

xR34P3Rx
  • 395
  • 9
  • 28
  • Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. (copied from flag box) – gparyani Aug 17 '13 at 05:07
  • ok ill try something and post it in a bit – xR34P3Rx Aug 17 '13 at 05:09
  • Here's an idea: Use a `BorderLayout` manager. Put the banner in the North region, the image space in the East region, and panels 1-3 in a `JPanel` with a `BoxLayout` layout manager into the West region. – gparyani Aug 17 '13 at 05:11
  • hmm, yea i think that could work, i dont use that very often i completely forgot about it. ill give it a shot :) – xR34P3Rx Aug 17 '13 at 05:15
  • @gparyani That would not work because the white space would also appear to the east of the banner, and judging by his diagram, that isn't what he wants. – Josh M Aug 17 '13 at 05:17
  • hmm, so ur saying that the east white space (really im going to add a label and give it an imageicon to add the images) it will overtake the north regions space? – xR34P3Rx Aug 17 '13 at 05:19
  • @xR34P3Rx It will appear next to components at the top, center, and bottom. Look at my answer for how it will most likely look like. I wouldn't use a `BoxLayout` for this 3 vertically placed components at the bottom left because you might get unexpected results. From the looks of your diagram, it appears everything is everything proportionate, which is when I used a `GridLayout` which stretches the `Component` to fill the `Container`. Which means that the 3 components will have the same size. – Josh M Aug 17 '13 at 05:22
  • hmm to make it easier, i think i can squish the 3 Panels into 1 using GridLayout, so then it wud be like the banner at the top and the bottom part divided, which i think i can use North Ease and West with no problem. wat do u think? – xR34P3Rx Aug 17 '13 at 05:31

1 Answers1

0

This would give you your desired result:

    final JPanel mainPanel = new JPanel(new BorderLayout());
    final JPanel bottomLeftPanel = new JPanel(new GridLayout(3, 1));
    //add 3 panels to bottomLeftPanel
    final JPanel bottomRightPanel = new JPanel(new BorderLayout());
    final JPanel bottomPanel = new JPanel(new GridLayout(1, 2));
    bottomPanel.add(bottomLeftPanel);
    bottomPanel.add(bottomRightPanel);
    final JPanel topPanel = new JPanel(new BorderLayout());
    mainPanel.add(bottomPanel, BorderLayout.CENTER);
    mainPanel.add(topPanel, BorderLayout.NORTH);
Josh M
  • 11,611
  • 7
  • 39
  • 49