Solved

Dynamic naming of form objects in SWT

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

717 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