Solved

Dynamic naming of form objects in SWT

Posted on 2004-09-24
4
731 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet  URL Rewriting 1 36
HashTable highest marks enumeration alternative 9 37
jdbc error in jsp application 20 44
tomcat administrtor 12 46
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)
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

815 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

11 Experts available now in Live!

Get 1:1 Help Now