Ok, so basically I made a little image of what is supposed to happen. The goal is that there is a JComboBox, and below it is a Jpanel that updates when different options are selected from the JComboBox, there are about 6-7 different forms/options that each appear when a different option is picked. I am trying to find a way to do this and am getting very lost.

I am using NetBeans for this project. I have tried throwing panels "over" each other, but that just moves everything around in the GUI design mode and won't let me stack them..so there is some sort of hidden option I am missing that would make this a lot easier? I feel like there is, and Google just isn't helping me find that option.

Once I figure it out, I am just going to have a listener that updates when a new item is selected, and when it does, to just hide all the panels except for the one that I want displayed in the box.

Thanks

Attachments help.png 40.39 KB

If you have separate panels for each group of controls, you can simply swap those in and out of a target panel that remains in a fixed place in your UI.

To swap them, remove the old panel, add the new, and call targetPanel.revalidate() and targetPanel.repaint().

not sure how id do that in netbeans with a predefined GUI..It doesnt let me stack panels. hmmm

if you'll start with hand_made code, and for the BorderLayout no needed to remove un-wanted JCOmponent, only add new and then call revalidate + repaint

Hmmmm, I just feel like the way Netbeans works in design mode will end up arousing some size and resizing issues within the premade GUI panel that everything will be displaying on.

aanders5, you can also try null layout , which allows you to put your components (in this case your panels) one over the other

not never ever do that, don't use AbsoluteLayout, never !!!, AbsoluteLayout is one of the reasons why this Java Forum exists

Edited 5 Years Ago by mKorbel: n/a

This article has been dead for over six months. Start a new discussion instead.