Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages
Started by john
Mon, 19 Jul 2004 09:52
Referencing a component from a string
Author: john
Date: Mon, 19 Jul 2004 09:52
Date: Mon, 19 Jul 2004 09:52
4 lines
1138 bytes
1138 bytes
Is there a way to reference a component when all you have is a string with the name of the component in it? The component has been created in the code. A sequence is used to create unique names for the component so all i have is a string with for the name.
Re: Referencing a component from a string
Author: Kevin Dean
Date: Mon, 19 Jul 2004 11:34
Date: Mon, 19 Jul 2004 11:34
26 lines
1882 bytes
1882 bytes
Assuming that the component is accessible to the class that wants to access it, you can find the component using the Java Reflection API: Field f = container.getClass().getField(componentName); Component c = (Container)f.get(container); -- Check out our latest white papers at http://www.datadevelopment.com/papers/index.html BladeNET Scores With Borland Enterprise Tools Team Development with JBuilder and Borland Enterprise Server Dolphin Data Development Ltd. http://www.datadevelopment.com/ "john" <john.butler@crowderconsult.co.uk> wrote in message news:40fb99d1$1@newsgroups.borland.com... > Is there a way to reference a component when all you have is a string with > the name of the component in it? The component has been created in the code. > A sequence is used to create unique names for the component so all i have is > a string with for the name. > >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads