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 / General / July 2007

Tip: Looking for answers? Try searching our database.

Fast Question: Index of a Component in another component

Thread view: 
pek - 23 Jul 2007 16:36 GMT
So I have a JPanel that is a container for a number of JLabels. Let's
say I have a reference for a particular JLabel that is in the JPanel's
component list. How can I find the index of the JLabel in the
JPanel..? JPanel has a getComponent(int index). What about the
oposite..?

Sorry for the trouble..
Roedy Green - 23 Jul 2007 20:21 GMT
>JPanel..? JPanel has a getComponent(int index). What about the
>oposite..?
Not likely.  Every time a element were added or deleted, the embedded
index number would have to be updated in every Component.  It would be
faster just to scan the component list when you need the reverse
index.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

pek - 24 Jul 2007 01:37 GMT
On Jul 23, 10:21 pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Mon, 23 Jul 2007 08:36:45 -0700, pek <kimwl...@gmail.com> wrote,
> quoted or indirectly quoted someone who said :>JPanel..? JPanel has a getComponent(int index). What about the
[quoted text clipped - 7 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

Oh, I see. I was just wondering if there was a method like List's int
indexOf(T element). Anyway, thnks..
Roedy Green - 24 Jul 2007 02:56 GMT
>Oh, I see. I was just wondering if there was a method like List's int
>indexOf(T element). Anyway, thanks..
You are SOL. Inside Component you will see
Component component[] = new Component[0];
It is default scope. So if you extended Container, you could not
access the array of children to do the scan.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



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.