Performs an action assigned to the convertUnits entry-point.
()
| 2348 | * Performs an action assigned to the convertUnits entry-point. |
| 2349 | */ |
| 2350 | public void convertUnits() {//GEN-END:|683-entry|0|684-preAction |
| 2351 | // write pre-action user code here |
| 2352 | |
| 2353 | /* |
| 2354 | * Converting units |
| 2355 | */ |
| 2356 | UnitGroup group = UnitGroup.GROUPS[unitGroups.getSelectedIndex()]; |
| 2357 | Unit[] units = group.units; |
| 2358 | Unit unitFrom = group.units[this.unitFrom.getSelectedIndex()]; |
| 2359 | Unit unitTo = group.units[this.unitTo.getSelectedIndex()]; |
| 2360 | |
| 2361 | double quantityFrom = |
| 2362 | Double.parseDouble(numberBox.getString()); |
| 2363 | double quantityTo = round(Unit.convert(quantityFrom, unitFrom, unitTo)); |
| 2364 | |
| 2365 | getResultFromQuantity().setText(Double.toString(quantityFrom)); |
| 2366 | getResultFromUnit().setText(unitFrom.name); |
| 2367 | getResultToQuantity().setText(Double.toString(quantityTo)); |
| 2368 | getResultToUnit().setText(unitTo.name); |
| 2369 | switchDisplayable(null, getConversionResult());//GEN-LINE:|683-entry|1|684-postAction |
| 2370 | // write post-action user code here |
| 2371 | }//GEN-BEGIN:|683-entry|2| |
| 2372 | //</editor-fold>//GEN-END:|683-entry|2| |
| 2373 | |
| 2374 | //<editor-fold defaultstate="collapsed" desc=" Generated Getter: RESTART_COMMAND ">//GEN-BEGIN:|695-getter|0|695-preInit |
no test coverage detected