Skip to content
Advertisement

JTextField render bug if Text-Not-Fitting (JDK 7 till 18)

JTextField has wrong text render on RIGHT_TO_LEFT component orientation

We need a workaround, since whenever JTextField is filled with text that contains:

  • Right to left text like Arabic,
  • Latin numbers,
  • and Latin text.

Then JTextField renders text parts at unexpected locations.

(It only renders right if the complete text Fits inside the JTextField.)

The text we use to reproduce is:

  • صندوق ۴۰×۳۰ پایه دار وایرنگ میتر تک فاز

Other info:

  • Above text is just name of a product, added inside an accounting software we created, but our users have match more render failures than we could reproduce.
  • We reported at: JDK-8194733
  • We have no experience with a custom-render in Java to make workaround, but render of entire text not considering the limit, and clipping that, should do the trick.

Source code for an executable test case:

JavaScript

Screen shots

Just running above code results to:
just run

After resize, to something less:
after resize


Development Kit or Runtime version:

  • java version “1.8.0_25”
  • Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
  • Java HotSpot(TM) Client VM (build 25.25-b02, mixed mode)

Advertisement

Answer

You can try this

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement