R
Rick
Hi,
I'm having trouble resizing a JFrame... okay, don't laugh.. I know this
is pathetic and I'm sure I'm missing out something here. Here's what I'm
trying to do:
I have a JFrame, that contains a JSplitPane. On the Left side of the
JSplitPane, I have a JPanel, on top of which I have two more panels, one
on BorderLayout.SOUTH and one on BorderLayout.NORTH.
On the Right side of the JSplitPane, I have another JPanel on which I'm
drawing something. Now the problem is that at runtime I need to "resize"
the Top panel (only it's Height) contained in the JSplitPane according
to some runtime measurments. I do that by using the setBounds() and
setSize() method (for some reason if I don't use both of these, it
doesn't work). In effect, the top panel get's resized and covers the
lower panel. So now I do the same with the lower panel, i.e., I resize
it by first 'setBound'ing it to start from (0, topPanel.getHeight). The
lower panel get's resized and is adjusted (I wonder if that's the
correct way of doing it because the underlyingpanel has a BorderLayout
and I was hoping the lower panel would "automagically" align itself but
that's not the case.. since I changed the bounds for the first panel, I
had to position the lower one myself).
The problem is that the JFrame itself does not change its size
automatically to accomodate the new JPanels. When I try doing this in
the paint() method or by writing my own method (something like
resetSize), it just doesn't work and it starts to flicker sometimes,
becomes extremely slow and even when it does resize, the portion of the
frame that resized is Grey and half of the JSplitpane is not visible.
It's just grey. I tried 'setBound'ing it, setSizing it.. everything! I'm
just going crazy over this and I'm sure there must be a cleaner, better
way to do what I'm trying to do. I just need to resize my JFrame and the
panels inside it according to some measurement I receive at runtime. Can
someone please help me out? Thanks!
Rick
I'm having trouble resizing a JFrame... okay, don't laugh.. I know this
is pathetic and I'm sure I'm missing out something here. Here's what I'm
trying to do:
I have a JFrame, that contains a JSplitPane. On the Left side of the
JSplitPane, I have a JPanel, on top of which I have two more panels, one
on BorderLayout.SOUTH and one on BorderLayout.NORTH.
On the Right side of the JSplitPane, I have another JPanel on which I'm
drawing something. Now the problem is that at runtime I need to "resize"
the Top panel (only it's Height) contained in the JSplitPane according
to some runtime measurments. I do that by using the setBounds() and
setSize() method (for some reason if I don't use both of these, it
doesn't work). In effect, the top panel get's resized and covers the
lower panel. So now I do the same with the lower panel, i.e., I resize
it by first 'setBound'ing it to start from (0, topPanel.getHeight). The
lower panel get's resized and is adjusted (I wonder if that's the
correct way of doing it because the underlyingpanel has a BorderLayout
and I was hoping the lower panel would "automagically" align itself but
that's not the case.. since I changed the bounds for the first panel, I
had to position the lower one myself).
The problem is that the JFrame itself does not change its size
automatically to accomodate the new JPanels. When I try doing this in
the paint() method or by writing my own method (something like
resetSize), it just doesn't work and it starts to flicker sometimes,
becomes extremely slow and even when it does resize, the portion of the
frame that resized is Grey and half of the JSplitpane is not visible.
It's just grey. I tried 'setBound'ing it, setSizing it.. everything! I'm
just going crazy over this and I'm sure there must be a cleaner, better
way to do what I'm trying to do. I just need to resize my JFrame and the
panels inside it according to some measurement I receive at runtime. Can
someone please help me out? Thanks!
Rick