2010-12-18 69 views
1

我是新來的java,所以要溫柔。在java中分層JPanels?

我給JFrame添加了多個JPanel,並且我想讓它們分層,即其他的一個ontop,都是不同的大小。

查詢:爲什麼我必須首先添加我想要的面板?當然,這將是另一回合?

frame.add(panel2); 
frame.add(panel1); 

我想它會是另一種方式,但如果我這樣做,它不起作用。

回答

2

查看容器的方法。

/** 
* Returns the z-order index of the component inside the container. 
* The higher a component is in the z-order hierarchy, the lower 
* its index. The component with the lowest z-order index is 
* painted last, above all other child components. 
* 
* @param comp the component being queried 
* @return the z-order index of the component; otherwise 
*   returns -1 if the component is <code>null</code> 
*   or doesn't belong to the container 
* @see #setComponentZOrder(java.awt.Component, int) 
* @since 1.5 
*/ 
public int getComponentZOrder(Component comp) { 
     } 
+0

你是來自Oracle/Sun論壇的Stanislav嗎?如果是這樣,很高興在這裏見到你! – 2010-12-18 12:59:48

+0

是的:-)我是一樣的。但是,我所有的> 1000名公爵都在那裏失去......在舊的SUN論壇上。 – StanislavL 2010-12-18 14:30:46