🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #13246

Re: Changing Z-order with swing components

#13246
From: Ethan Henry
Date: Tue, 25 Aug 1998 00:00
22 lines
2013 bytes
John P. McGrath wrote:
> 
> > I have noticed that there is no bringToFront() or sendToBack() methods
> > for JComponents in order to change the Z-order of the GUI.  
>
> The way to do this is to remove() the component from the container 
and then add() it again.  If you do not remove it first, it will be 
automatically removed first, but I would recommend doing the remove.  Otherwise it makes the interpretation of the add() index argument a little confusing.
> 
> When you add the component, if you do not specify an index, it goes at the "end" (as the Sun docs say), which means in the back.  (I have always thought this was strange -- the default should be on top).  To bring it to the front, you specify the index equal to the number of components in the window.
> 
> This may seem strange, but it really is not much of a problem.  It was a problem with heavyweight AWT components, since this resulted in the peer being deleted and then re-created.  But with Swing, there is not much that would be saved with a moveToFront() or moveToBack() method.  However, it would be a lot nicer if Sun would add those methods -- it would make the code a _lot_ more clear.
> 
> --
> John P. McGrath
> <mcgrath@enter.net>
> <jpm@nscs.fast.net>

--
Ethan Henry                                            egh@klg.com
Java Evangelist, KL Group                       http://www.klg.com
               "Software Development Productivity"
Technical Details
Message-ID: <35E2DC2B.1844DD98@klg.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <35C96DEF.5737511D@gic-net.com> <01bdc5c5$c6cb18b0$1a47aacc@ferd>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,f15b637c03713beb
X-Google-Attributes: gid111d45,public
From: Ethan Henry <egh@klg.com>
Subject: Re: Changing Z-order with swing components
Date: 1998/08/25
Message-ID: <35E2DC2B.1844DD98@klg.com>
X-Deja-AN: 384585284
Content-Transfer-Encoding: 7bit
References: <35C96DEF.5737511D@gic-net.com> <01bdc5c5$c6cb18b0$1a47aacc@ferd>
Content-Type: text/plain; charset=us-ascii
Organization: KL Group Inc.
Mime-Version: 1.0
Reply-To: egh@klg.com
Newsgroups: borland.public.jbuilder.java.swing