2016-04-21 95 views
0

我想補充一個JPanel地圖上的其他JPanel的世界觀的頂部,在它的中心就是這樣的如何在另一個JPanel的中心添加一個JPanel?

Example

這裏是我的代碼:

public class WorldView extends JPanel implements ActionListener{ 

private JPanel map; 

public WorldView() throws IOException{ 
    this.setSize(1024,768); 
    this.setBackground(Color.BLACK); 
    map = new JPanel(); 
    this.add(map); 
} 
+0

而你試圖做什麼來使它從現在到現在成爲你想要的?它現在做了什麼?你有任何錯誤,或者你不知道從哪裏出發? –

回答

0

在constrctor補充一點: 的setLayout (新的FlowLayout(FlowLayout.CENTER));

+2

無論如何,這是「JPanel」的默認設置 – MadProgrammer

相關問題