...

View Full Version : How to replace the items in an AWT List



jmitch18
02-06-2008, 04:37 PM
I have a project at the minute which is basically a medical conditions and symptoms database. Basically the idea is that the user can select a symptom from one List which will then update another list with all the related condition. Then the user can select a condition from that list and view information on it.

The problem occurs when I try to update the conditions list after a symptom has been selected. The action event works fine but I just can't make it update the conditions list. Here is the method that's supposed to do that



private void getConditions(String selected)
{
db.result = db.selectQuery(query);
String[] conditionList = db.stringArray(db.result, "conditionName");

conditions = new List(10);
for(int i = 0; i < conditionList.length; i++)
{
conditions.add(conditionList[i]);
}
}


I tried using conditions.removeAll() to empty the list but it always produced a run-time error so I decided to try making a new List but no luck. The list is inside a JPanel.

Anyone got any ideas on how to solve this?

shyam
02-06-2008, 09:39 PM
I tried using conditions.removeAll() to empty the list but it always produced a run-time error

what was the error?

jmitch18
02-09-2008, 11:34 PM
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at SymptomSelect.getConditions(SymptomSelect.java:47)
at SymptomSelect.actionPerformed(SymptomSelect.java:34)
at java.awt.List.processActionEvent(Unknown Source)
at java.awt.List.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

shyam
02-09-2008, 11:54 PM
are u sure db is not null and db.stringArray does not return a null?

jmitch18
02-10-2008, 06:59 PM
Yeah I just made a loop to print each index of conditionsList to the console and they appeared alright.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum