/** Update the interface display to show the current value of the calculator. */ private void redisplay() { if (calc.isHexOn()) { int displayInt = calc.getDisplayValue(); if (displayInt < 0) { // toHexString() returns an unsigned integer as a String, // meaning negative values return (String)(ffffffff - n) instead of (-n) // example: -9 would show ffffffff - 9 = fffffff4 display.setText("-" + Integer.toHexString(Math.abs(displayInt))); } else { display.setText(Integer.toHexString(displayInt)); } // show all hexButtons since hexSwitch is true hexPanel.setVisible(true); } else { display.setText("" + calc.getDisplayValue()); // hide all hexButtons since hexSwitch is false hexPanel.setVisible(false); } }