Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2006

Tip: Looking for answers? Try searching our database.

sliding component

Thread view: 
VisionSet - 20 Jun 2006 09:21 GMT
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!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.