?
Solved

Dynamic naming of form objects in SWT

Posted on 2004-09-24
4
Medium Priority
?
750 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month10 days, 2 hours left to enroll

762 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