Yes I do want one. I have a tiny app launched from an applet that has
a login widget in BorderLayout.NORTH, when the user has logged on they
won't need the widget again so I want to slide it out to give feedback
that it has intentionally been removed.
I've tried gradually reducing preferred height and validating &
repainting but it does nothing till he eventual removal:
public void remove(JComponent cont) {
Dimension dim = getPreferredSize();
while (dim.height > 0) {
try {Thread.sleep(100);}catch(Exception ex) {}
--dim.height;
setPreferredSize(dim);
cont.validate();
cont.repaint();
System.out.println(dim.height + " : " + getPreferredSize());
}
cont.remove(this);
}
Any tips?
TIA,
Mike W
Bart Cremers - 20 Jun 2006 10:17 GMT
There are a few things you'll have to keep in mind when doing such a
thing.
You'll have to make sure the resizing is not done in the event dispatch
thread. No repaints will occur as long as the resizing code is running.
So to do this launch a separate thread for the repainting.
Simply repainting the container is not enough. You'll have to make sure
the container isseus the layoutmanager to re-layout the components.
That way the changes in preferredsize are reflected on the screen. To
do this first invalidate the widget and then call validate() on the
container. Also do a validate() on the container after you remove the
widget.
Regards,
Bart
VisionSet - 20 Jun 2006 10:43 GMT
...
Thanks Bart, my Swing's a bit rusty!