Solved

Dynamic naming of form objects in SWT

Posted on 2004-09-24
4
726 Views
Last Modified: 2012-05-05
I am trying to create a form that will build itself from a XML file.  I've got it working but can't fugure out how dynamicaly name the form objects ( text fields, drop downs, etc.) based on the name specified in the XML file.

This is what I'm doing now:
Label label = new Label();

What'd I like to do is this:
Label "name from XML file" = new Label();

Thanks.
0
Comment
Question by:radixk
  • 3
4 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12147367
Use hastable

like

Hashtable ht=new Hashtable();

ht.put("name from xml file",new Label());


then retreive like this
Label l=(Label)ht.get("name from xml file");
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12147384
dynamic creation of variables is not possible. You should depend either on Hashtable or Hashmap for this
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 125 total points
ID: 12147403
Hashtable ht=new Hashtable();

ht.put("xmlelement1",new Label());
ht.put("xmlelement2",new Label());
ht.put("xmlelement3",new Label());
ht.put("xmlelement4",new Label());
ht.put("xmlelement5",new Label());


now if you want to access label 3

then

((Label)ht.get("xmlelement3")).Your method Executions()  here
0
 

Author Comment

by:radixk
ID: 12164502
Perfect.  Thanks.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now