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

if you want to stack your panels try using "card layout" fro that..

Member Avatar for hfx642

Try...

My_Panel.setVisible (true|false);

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.

If you insist on using a GUI designer for everything then you'll probably have to use card layout, as efxee mentioned above.

aanders5

Can you post your code?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.