Using a layout to add a component on another component
Hi,
I'm trying to create a specific layout and I don't seem to manage.
I have a JPanel, and I want it it to have 2 component:
A component that will spread in the JPanel, and a JButton that will hover over the first component in a static position.
I known I can use the panel without a layout manager, but then each time the JPanel size changes, the first component won't spread.
Is there a layout that can help me in this? Or is there a way to do it?
Thanks!
Yoav
[515 byte] By [
ymoran00a] at [2007-11-27 8:15:17]

# 3
I've tried using Component Listener.
Something isn't right.
The code looks like that:
I''ve written this in the constructor of the JFrame:
m_outerPanel = new ADPanel();
m_outerPanel.add(m_innerPanel);
m_outerPanel.addComponentListener(new MyComponentListener());
m_innerPanel.setBounds(m_outerPanel.getBounds());
and then added this class:
public MyComponentListener extends ComponentAdapter {
@Override
public void componentResized(ComponentEvent componentevent) {
Rectangle bounds = componentevent.getComponent().getBounds();
m_innerPanel.setBounds(bounds);
}
}
It seems that the inner panel is smaller than the outer panel. Any idea why?
# 4
Ok, I managed to create null layout.
Now the two components are one on top of the other - but there's still a problem.
Once one of the components receive the focus, it moves in fromt of the other. But I need the button to be on top of the first panel - no matter what.
How can I bypass that?