I am trying to make a unit converter in LWUIT, and I am working with two comboboxes.
The application basically converts the unit selected in one combobox to the unit selected in other combobox.
http://www.unit-conversion.info/length.html#data
It works like this online converter.
I have made it successfully, but I am facing a problem regarding comboboxes.
When I select an item on a combobox and then select an item on another combobox, the selection of previous combobox is lost.
Due to that I have to select the combobox again and again multiple times even when I want my one unit to be fixed.
I want my application to work like this online unit converter where the selection once made is fixed till another selection is made.
So is there any method which retains your selection till you haven't manually changed it?
I can't upload any image due to my low rating and providing code would be of no use as it's too lengthy and it works fine for the most part.
Please I need help, any info would be really helpful.
Form b = new Form();
String content = {"contents here for combobox 1"};
String content2 = {"contents here for combobox 2"};
TextArea value1 = new TextArea();
value1.setConstraint(TextArea.DECIMAL)
TextArea value2 = new TextArea();
value2.setEditable(false);
final ComboBox V2 = new ComboBox(content2);
V2.setListCellRenderer(new checkBoxRenderer1());
final ComboBox V1 = new ComboBox(content);
V1.setListCellRenderer(new checkBoxRenderer());
V1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
int a = V1.getSelectedIndex();
switch(a){
case 0:
int v2sel = V2.getSelectedIndex();
switch(v2sel){
case 0 :
double d1 ;
value2.setText(value1.getText());
break;
case 1 :
d1 = Double.parseDouble(value1.getText());
d1 = d1 * 0.1;
value2.setText(Double.toString(d1));
break;
case 2 :
d1 = Double.parseDouble(value1.getText());
d1 = d1 * 1.0e-5;
value2.setText(Double.toString(d1));
break;
// multiple case statements
}
//multiple case statements
}
});
b.addComponent(V1);
b.addComponent(value1);
b.addComponent(V2);
b.addComponent(value2);
b.addComponent(Bexit);
b.show();
// End