P
Pierre Vigneras
Hi,
I've the following problem:
two frames A and B are displayed, A is resizable whereas B is not. A
contains a JPanel Pa (A.setContentPane(Pa)), and B a JPanel Pb
(B.setContentpane(Pb)). Each JPanel contains no components, they are
only used for painting.
When the user resize A, I want to resize B as well to exactly the same
size. So, I use the following code:
Pa.addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
public void ancestorResized(HierarchyEvent e) {
resizeOtherFrame();
}
});
where resizeOtherFrame() is:
void resizeOtherFrame() {
B.setSize(A.getSize());
Pb.setSize(Pa.getSize());
}
Hence, when the user resize frame A with the mouse, the B frame is
resized too. But the problem is that when Pb draws, it only draws on a
portion of the region available. As if something between B and Pb has
not been resized (maybe the RootPane?). Sun tutorial says that some
LayoutManager does not use the size attribute (such as
BorderLayout). But others do (BoxedLayout, SpringLayout). The problem
is that my JPanel Pa and Pb does not have to layout something, hence
they have a LayoutManager set to null! It is the JFrame wich must
layout my JPanels (its content pane!). Maybe I must specify a
LayoutManager such as SpringLayout (which uses the size attribute) to
the JFrame B, but how?
What is wrong ?
--
Pierre Vigneras
http://www.labri.fr/~vigneras/
Distributed Objects Systems
LaBRI
http://www.labri.fr/
I've the following problem:
two frames A and B are displayed, A is resizable whereas B is not. A
contains a JPanel Pa (A.setContentPane(Pa)), and B a JPanel Pb
(B.setContentpane(Pb)). Each JPanel contains no components, they are
only used for painting.
When the user resize A, I want to resize B as well to exactly the same
size. So, I use the following code:
Pa.addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
public void ancestorResized(HierarchyEvent e) {
resizeOtherFrame();
}
});
where resizeOtherFrame() is:
void resizeOtherFrame() {
B.setSize(A.getSize());
Pb.setSize(Pa.getSize());
}
Hence, when the user resize frame A with the mouse, the B frame is
resized too. But the problem is that when Pb draws, it only draws on a
portion of the region available. As if something between B and Pb has
not been resized (maybe the RootPane?). Sun tutorial says that some
LayoutManager does not use the size attribute (such as
BorderLayout). But others do (BoxedLayout, SpringLayout). The problem
is that my JPanel Pa and Pb does not have to layout something, hence
they have a LayoutManager set to null! It is the JFrame wich must
layout my JPanels (its content pane!). Maybe I must specify a
LayoutManager such as SpringLayout (which uses the size attribute) to
the JFrame B, but how?
What is wrong ?
--
Pierre Vigneras
http://www.labri.fr/~vigneras/
Distributed Objects Systems
LaBRI
http://www.labri.fr/