Solved

Dynamic naming of form objects in SWT

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
session migration servlets 2 42
more than one jdk and one jre 1 50
difference of if loops 23 62
Tomcat: Unable to run tomcat service. 2 23
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.

856 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