I wish Oracle simply included this feature so developers would not have to code it from scratch. However, I came across a custom made class called ScrollFreeTextArea from the javafx-demos website.

This class simply did the trick for me. So whenever you type a long text and it wraps itself or press the ENTER key for a new line, the height of the TextArea increases without displaying the scrollbar.

Here is the complete source code.

The first time I encountered this I really did not pay much attention but after experiencing it the second time in my other ComboBox, I decided to look into it.

The issue happens when I click on the ComboBox the first time and the popup menu list that is shown has its width very short. The second time I click on the ComboBox and the list is shown again, the width is now correct as the width of the list now aligns itself with the ListView.

combobox_popup_width_small

Seems this is a bug in Java FX 2. User shakir.gusaroff in the Oracle forumprovided an insightful answer regarding this issue.

There is a bug: https://javafx-jira.kenai.com/browse/RT-28876 where the ComboBox popup list is set with the wrong width the first time it is shown if it is wider than prefWidth.

This is fixed in Java FX 8.0 already, but not in Java FX 2.

There is more than one way to get a browser’s width and height using Javascript. But some of the ways are for specific browsers only. It works with Mozilla type browsers but not with Internet Explorer. If this certain code works with IE, it does not with Mozilla type browsers. This code typically works on many browsers so use this one to avoid having problems with the different web browsers.

Related Posts Plugin for WordPress, Blogger...