javafx - 为什么 JavaFX 会模糊控件以及如何修复它?

标签 javafx scenebuilder

我有这个简单形式的 JavaFX 应用程序,它有两个没有样式属性的 TextArea:

enter image description here

查看表单时我看到了这个:

enter image description here

此处为 FXML 代码:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>


<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <TitledPane animated="false" prefWidth="300.0" text="untitled" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
         <content>
            <TextArea prefHeight="200.0" prefWidth="200.0" />
         </content>
      </TitledPane>
      <SplitPane dividerPositions="0.5" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="300.0" AnchorPane.topAnchor="0.0">
        <items>
          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
               <children>
                  <TitledPane animated="false" text="untitled" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                    <content>
                      <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
                           <children>
                              <TextArea prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="-10.0" AnchorPane.leftAnchor="-10.0" AnchorPane.rightAnchor="-10.0" AnchorPane.topAnchor="-10.0" />
                           </children>
                        </AnchorPane>
                    </content>
                  </TitledPane>
               </children>
            </AnchorPane>
          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" />
        </items>
      </SplitPane>
   </children>
</AnchorPane>

第一个 TextArea 中的文本模糊。为什么会发生以及如何解决?

最佳答案

当您使用此组合时会出现问题:TitledPane -> AnchorPane(哪些元素嵌入到 AnchorPane 中并不重要)。当您使用 AnchorPane 约束工具时,嵌套元素会获取宽度、高度、LayoutBounds、BoundsInLocal 和 BoundsInParent 值的工件。这些伪像会影响模糊。

无限制: enter image description here

有限制: enter image description here

为了解决问题,不要使用组合 TitledPane-> AnchorPane 或不要使用工具 AnchorPane Constraints。

关于javafx - 为什么 JavaFX 会模糊控件以及如何修复它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41950075/

相关文章:

javafx - 如何在 JavaFX SceneBuilder 中更改 gui 字体大小?

java - 有没有办法在Javafx中获得图像的最主要颜色

java - 如何检测屏幕方向变化? - Microsoft Surface 上的 JavaFX

java - 将 javafx 中的表格上传到 Excel 工作表

Javafx - 场景生成器 - 如何获取表的选定值

javafx - 场景生成器 2.0。 FXML 导入不工作

java - ShellIpcClient 和 NonCelloThread 错误 java

JavaFX : Consuming REST service and displaying the data in front-end

macos - javafx FileChooser Mac 操作系统 NSInternalInconsistencyException

java - 场景生成器嵌套自定义节点