问题描述
我在JavaFX中调整TextArea的更新/事件大小时遇到问题。为了说明,我通过IntelliJ Idea创建了空JavaFX项目,并将AnchorPane作为根窗格,并且AnchorPane包含带有预期的TextArea AnchorPane.bottomAnchor =0.0AnchorPane.leftAnchor =0.0AnchorPane.rightAnchor =0.0AnchorPane sample.fxml文件中的.topAnchor =0.0
(简而言之:TextArea占用场景的所有空间)。
I have a problem with resizing update/event of TextArea in JavaFX. For illustration I created empty JavaFX project through IntelliJ Idea with AnchorPane as root pane and that AnchorPane contains TextArea with propecties AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
in sample.fxml file (in a short: TextArea takes all space of scene).
问题说明:我启动应用程序,它从一个小窗口(300 x 275)开始。我只是最大化它。有正常的行为,但当我回到窗口时,两个滚动条都显示出来了。当我将窗口调整到较小的窗口时,会发生类似的情况。当我开始滚动时,TextArea视口没有任何反应。当我开始写一些字母或调整窗口大窗口时,滚动条消失了。这是非常奇怪的行为!
Problem description: I launch application and it starts in a small window (300 x 275). I just maximalize it. There is normal behavioral, but when I got back in a window, both of scrollbars were shown. The similar situation happens when I am resizing window into smaller window. When I start with scrolling, nothing happens with TextArea viewport. When I start to write some letter or resize window into bigger window, scrollbars disappeared. That's very strange behavioral!
我的问题:在没有必要时,是否有任何用于捕获/停止显示滚动条的侦听器或方法?您是否也遇到过这个问题?
My question: Is there any listener or method for catch/stop showing scrollbars when it isn't necessary? Have you got this problem too?
从最大化表单返回后的屏幕截图
Main.java
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Controller.java
package sample;
public class Controller {
}
样本.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="480.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<children>
<TextArea layoutX="162.0" layoutY="66.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
PS:对不起我的英文并重复插入该问题,但是如果是bug的话JavaFX,解决问题的地方非常紧急!
PS: Sorry for my english and repeat insertion of that question, but if it's bug of JavaFX, it's very acute to resolve where is problem!
推荐答案
这个错误似乎在JDK 8u60中得到修复。至少我不能再在我的MacBook Pro(Retina)上重现它了。因此,不再需要复杂的工作了:-)(也许有人非常友好地为Windows确认。)
Michael
This bug seems to be fixed in JDK 8u60. At least I can't reproduce it anymore on my MacBook Pro (Retina). So there is no need anymore for a complicated work arround :-) (Maybe someone is so kind to confirm that for Windows too.)Michael
这篇关于JavaFX TextArea - 调整大小时不需要的ScrollBars的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!