Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6404183

Swing Examples parse floating point text unnecessarily and/or using non-localizable API

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 1.2.1
    • docs
    • None
    • b65
    • unknown
    • generic
    • Verified

      Here's a Tutorial Feedback comment:

      name: Rene Grothmann
      email: ###@###.###
      referer: CelsiusConverter2.java
      subject: Technical Error
      comments: The example will not run in German, and probably other foreign systems.

      This is because tempCelsius passes the string as e.g. "37,0" to Double.parseDouble(). A NumberFormatException will be thrown on line 92 of the source code.

      Rene is correct. The problem is that parseDouble isn't localizable. The new Scanner object is more appropriate. Besides, there's no reason to accept floating point input, since the example always produces integer output. All Swing examples should be examined for these issues. We do not want to promote bad coding practices.

            sharonz Sharon Zakhour (Inactive)
            irabinovsunw Isaac Rabinovitch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: