Lijo
Lijo

Reputation: 6788

Switch between different JPanels in one JFrame

What I am looking for is a way to navigate through different JPanels in just one JFrame. To navigate the user should use buttons located inside these panels.

I am no using any layouts. I want all my jpanels in the same position.when we submitting the corresponding button

I hope you guy's can help me out, i Have a menubar in my jframe and for each item different panels.

Upvotes: 0

Views: 351

Answers (1)

MadProgrammer
MadProgrammer

Reputation: 347334

You will want to use a CardLayout, it was designed to allow you to switch the active panel from one panel to another.

Unless you intend never to run you program on any other PC other then the one it was created (and never update the OS or hardware), you will want to learn to make use of layout managers.

PC's come in all shapes and sizes, with differences between OS's (and versions of OS's), display drivers and screens which will all make your program look different on each system it is run on. Layout managers take out the guess work involved in trying to deal with these situations.

Upvotes: 5

Related Questions