tags:

views:

84

answers:

3

I need to get two JPanels into one JApplet.

paneel = new RekenmachinePaneel();
nummer = new NummerPaneel();
setContentPane(paneel);

Now I need to get the nummer panel to show up beneath the paneel. How should I do that?

A: 

Make the layout as null.

paneel.setLayout(null);
nummer.setLayout(null);

By setting the layouts to null, you can move any panels over any panel. But its not recommended as you will not be using the power of layouts (form, border, box etc.,)

Also you would need to the location of the panels properly.

paneel.setLocation(x2,y2);
nummer.setLocation(x1,y1);
Bragboy
A: 

You can use a layout to position them.

setLayout(new GridLayout(0,1));
add(paneel);
add(nummer);
Robber
All the layouts are tight meaning you will not be able to place one beneath the other. You should use NULL layout to achieve what he has asked.
Bragboy
A: 

If you want to add both panels you will have to create a third one:

JPanel myPanel = new JPanel();
myPanel.add(paneel);
myPanel.add(nummer);
setContentPane(myPanel);

If you want to get the number of panels you have inside an specific component use this:

int no = yourComponent.getComponents().length;
Enrique
thanks! this one worked!
baklap