I have a problem in javafx text area: When I focus the text area, border is applied... that is ok.
But when I drag with scroll-bar handle, the text area border focus is lost.
See the image below:
This is the my simple text area:
Text area changed when focused like this:
But when I scroll in text area with the scroll handle, the border is changed like before (un-focused) state:
Is there any way to control text area within scroll pane (in text area)?
One possible work around is to not allow focus on the ScrollPane within TextArea. ie., the moment ScrollPane gets focus we force to focus on TextArea. This way the focus will be always on TextArea.
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
public class CustomTextArea extends TextArea {
private ScrollPane textAreaScrollPane;
@Override
protected void layoutChildren() {
super.layoutChildren();
if (textAreaScrollPane == null) {
textAreaScrollPane = (ScrollPane) lookup(".scroll-pane");
textAreaScrollPane.focusedProperty().addListener((obs, oldVal, focused) -> {
if (focused) {
requestFocus();
}
});
}
}
}
And you will use this CustomTextArea across your application.
TextArea textArea = new CustomTextArea();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.