Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rewriting App in Swing

Status
Not open for further replies.

dcusick

Technical User
Aug 9, 2000
271
US
What's up all? I have a question for you... We've recently purchased a Java App from an outside company and took control of the source. They've written their own java app for building the GUI and reports. After using this, we've realized that it isn't that good, and would like to rewrite all the screens in the UI Level in Swing, while keeping all of the code on the Application Level the same.. My problem is that I can't figure out how to get the values(read from a DB) onto the new Swing components. Right now, the values are put into a hashtable. The current UI reads in the values and populates the text-boxes or combo-boxes or whatever... I need to implement this functionality, reading in data from the hashtable, and placing it in the components. Any ideas where to get started? The code also defines a propertyChangeSupport object and calls the firePropertyChange event. I would assume I need to use this, but don't know how to relate it to the GUI code that I'll be writing in Swing... Thanks in advance for your help...

Doug
 
Your question is a bit vague Doug.

All Swing components have handy get() and set() functions, as does the hash table. Aside from that I can offer no advice without being able to see the design of your code.

Sorry
Jo
 
I appreciate the response... My apologies for being so vague... Okay, let me give an extremely simplified sample of my code...

Code:
public class Calcs extends SimpleCalc implements 
	PropertyChangeListener, CollectionChangeListener {

	int newAge = 0;

	private static final String[] MY_PROPERTY_NAMES = {
		"age"
	};

	//Constructor
	public Calcs() {
		super("Calcs");
		pcs = new PropertyChangeSupport(this);
		propertiesMap = new Hashtable();
		propertyNames = MY_PROPERTY_NAMES;
		criteriaNames = CRITERIA_NAMES;
	}
	
	//Property Change listener...
	public synchronized void propertyChange(PropertyChangeEvent pce) {
		try {
			DLObject source = (DLObject)pce.getSource();
			String objectTypeName = source.getObjectName();
			String propertyName = pce.getPropertyName();

			if (interestedInProperty(propertyName)) {
				if (objectTypeName.equals("Person")) {
					if (propertyName.equals("Age")) {
						newAge = 45;
					}
			}
		}	catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	//Fill hash table
	private void fillProperties() {
		try {
			propertiesMap.put("age", newAge);
		}	catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

Right now, in the gui app they built, I just have to specify the "age" property and I can grab the value from the hashtable. I would like a simple SWING code that has a textbox that will display the "age" property, just to get started. I think after seeing this, I will be able to get the hang of it and expand it.. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top