2013-08-17 30 views
0

我有一個特定的網格我想打但林不知道如何使它如何在Java中創建此GridLayout?

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

所以我想知道我應該使用什麼樣的佈局管理器?

+0

問題要求代碼必須表現出對問題的理解最小正在解決。包括嘗試解決方案,爲什麼他們沒有工作,以及預期的結果。 (從國旗框中複製) – gparyani

+0

好吧生病嘗試一些東西,並將其發佈在 – xR34P3Rx

+0

這裏有一個想法:使用'BorderLayout'管理器。將旗幟放在北部地區,東部地區的圖像空間中,並將帶有「BoxLayout」佈局管理器的'JPanel'中的1-3放到西部地區。 – gparyani

回答

0

這將會給你想要的結果:

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);