Расслоение JPanels в Java? - PullRequest
       5

Расслоение JPanels в Java?

1 голос
/ 18 декабря 2010

Я новичок в Java, так что будьте осторожны.

Я добавляю несколько JPanels в JFrame, и я хочу, чтобы они были многослойными, то есть один поверх другого, оба разных размера.

Запрос: Почему я должен сначала добавить панель, которую я хочу, вверху?Конечно, это было бы наоборот?

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

Я думал, что это будет наоборот, но если я сделаю это таким образом, это не сработает.

1 Ответ

2 голосов
/ 18 декабря 2010

См. Метод контейнера.

/**
 * 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) {
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...