Hi,
I've finally managed to get my arrayList based program working, but there is one small item missing. When a user goes through the arrayList, forwards and backwards and then enters a new value it is automatically added to the end of the arrayList.
Does anybody know if there is a way to add this value to the current position in the list?
eg: a user enters 12,21,31,41,51 and then uses the index of these values to go back through the list to 21. They then enter a new value, 53, and want it saved after 21 but before 31.
What would be the best way to achieve this result?
My code for adding to the arrayList is currently as follows,
public class ClickAction implements ActionListener {
public void actionPerformed(ActionEvent event) {
// Parse degrees Celsius as a double
// and convert to Fahrenheit.
String celsiusAsText = tempCelsius.getText();
try { //start of the exception handling
Double celsiusAsDouble = Double.parseDouble(celsiusAsText);
double fahrenheitAsDouble = celsiusAsDouble*1.8+32;
fahrenheitLabel.setText(fahrenheitAsDouble + " Fahrenheit");
celsiusList.add(celsiusAsDouble);
fahrenheitList.add(fahrenheitAsDouble);
celsiusListCurrentIndex = celsiusList.size() - 1;//end of the list
fahrenheitListCurrentIndex = fahrenheitList.size() - 1;//end of the list
} catch(Exception e)
{fahrenheitLabel.setText("? Fahrenheit");}
}
}
Any advice or help appreciated!