Hi everyone
I have an instantiated Jframe containing a ComboBox and a JtextArea. Dependant on the item selected by the ComboBox, different text is displayed in the JtextArea. As far as I am aware, the information is applied correctly for display however the display does not update as expected to.
EXAMPLE: propertyChangeListener � ComboBox
private void dataSetComboBoxPropertyChange(java.beans.PropertyChangeEvent evt) {
// Change data set for viewing
this.setDataSet();
}
EXAMPLE: method called by propertyChangeListener
public void setDataSet(){
currentData.clear();
currentData.trimToSize();
dataDisplayArea.setText("");
comboIndex = dataSetComboBox.getSelectedIndex();
fm.getData(comboIndex);
sizer = fm.getDataSetSize();
System.out.println("New set size is: "+sizer);
for(int indexer = 0;indexer < sizer;indexer++){
currentData.add(fm.getDataString(indexer));
dataDisplayArea.append(currentData.get(indexer)+"\n");
dataDisplayArea.setCaretPosition(1);
}
}
The �System.out.println� is for testing purposes. It only produces the output when the Jframe is closed, hence my conclusion about the data being ready. I know the functional code for getting the ArrayList works ok.
Essentially, the information is updated after the Jframe is disposed. I�ve done some reading and am wandering if this issue related to the serializeable issue with objects and thus should I use a transient serializeable protocol on the JtextArea? Or am I way off the mark? Is this possible?
I have tried to implement a thread but it has no affect on the operation:
EXAMPLE: threaded method
Runnable update = new Runnable(){
public void run(){
currentData.clear();
currentData.trimToSize();
dataDisplayArea.setText("");
fm.getData(comboIndex);
sizer = fm.getDataSetSize();
for(int indexer = 0;indexer < sizer;indexer++){
currentData.add(fm.getDataString(indexer));
}
dataHeadersDisplay.setText(currentData.get(0));
for(int indexer = 1;indexer < sizer;indexer++){
dataDisplayArea.append(currentData.get(indexer)+"\n");
dataDisplayArea.setCaretPosition(1);
}
}
};
EXAMPLE: listener that calls the thread
private void dataSetComboBoxPropertyChange(java.beans.PropertyChangeEvent evt) {
// Get data set
new Thread(update).start();
}
Although, I am not sure I have implemented this correctly, it compiles and so assume it to be ok.
Many thanks for any advice.
Edited by: chewzLife on May 24, 2008 5:00 PM