【问题标题】:Javafx does not accept other fonts or languages in textArea of Text FieldJavafx 不接受文本字段的 textArea 中的其他字体或语言
【发布时间】:2020-11-30 06:37:47
【问题描述】:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import javafx.scene.control.*;
public class textareasss extends Application {
@Override
public void start(Stage stage) throws Exception {
    GridPane p = new GridPane();
    TextArea tx= new TextArea();
    p.add(tx,0,0);
    
    Scene sce = new Scene(p,600,600);
    stage.setScene(sce);
    stage.show();
 }
 }

Link to the screen shot

每次我在 javafx 文本区域或 TextField 中粘贴文本时,都不会显示文本,而是显示如下符号:????。

【问题讨论】:

  • java 命名约定请..
  • 我是 javafx 新手,但同样的错误也发生在其他 javafx 类中
  • 您是否考虑过可能安装的字体(JavaFX 能够从您的 PC 上获取)无法显示?尝试添加字体,将其应用于所有文本字段(通过 CSS 或代码)并再次检查。

标签: javafx textarea


【解决方案1】:

我运行了你的代码,它工作正常,JavaFX 不接受字体或语言没有错

这是我用的:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage stage) throws Exception{
        GridPane gridpane = new GridPane();
        TextArea text= new TextArea();
        gridpane.add(text,0,0);

        Scene scene = new Scene(gridpane,600,600);
        stage.setScene(scene);
        stage.show();
        }
    public static void main(String[] args) {
        launch(args);
    }

}

这是我得到的输出:

TextArea containing text in many languages

【讨论】:

  • 它对我不起作用。我有 javafx-sdk-14.0.2.1 和 java 版本“14.0.2” 2020-07-14 Java(TM) SE Runtime Environment (build 14.0.2+12-46) Java HotSpot(TM) 64-Bit Server VM (在我的 macbook 上构建 14.0.2+12-46,混合模式,共享)。
猜你喜欢
  • 1970-01-01
  • 2020-10-11
  • 1970-01-01
  • 2016-06-17
  • 2020-03-13
  • 2012-07-18
  • 1970-01-01
  • 2022-08-12
  • 1970-01-01
相关资源
最近更新 更多