user2796482
user2796482

Reputation: 53

how to automatically resize jPanel

I´ve created through NEtBeans design of jframe, when its components is created automatically. Now I put on this jFrame component jLayeredPane called agendaLayer, cause I need more panes here and switch. I´ve set horizontal and vertical resize to layout that component belong so it is automatically resize to some value when windows (jFrame) is resized..

Then I´ve created also through designer new class stock which extends jPanel,

now I put this jPanel to JLayredPane and need to get its properties about resizable..

stock st = new stock();
st.setBounds(0,0,agendaLayer.getWidth(),agendaLayer.getHeight());      
agendaLayer.add(st);

But It did not work, jLayredPane is automatically resized when window is changed, but jPanel not it remains the same..

Upvotes: 1

Views: 652

Answers (2)

Robert Sjödahl
Robert Sjödahl

Reputation: 754

You should look into layout managers: http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html

Upvotes: 1

camickr
camickr

Reputation: 324118

, jLayredPane is automaticaly resized when window is changed, but jPanel not it remains the same..

A JLayeredPane uses a null layout by default so components are never resized.

cause I need more panes here and switch.

If you need to switch panels then use a CardLayout. See the Swing tutorial on Using a Card Layout for more information and examples.

Upvotes: 1

Related Questions