private void update(DocumentEvent e) {
        try {
            int value = Integer.valueOf(textField.getText());

            if (value < 0 || value > 255) {
                throw new NumberFormatException();
            }

            if (value != slider.getValue()) {
                slider.setValue(value);
            }

            textField.setForeground(Color.BLACK);
        } catch (NumberFormatException e1) {
            textField.setForeground(Color.RED);
        }
    }