如何在JavaFX 2.0中更改插入符颜色? [英] How to change the caret color in JavaFX 2.0?

查看:106
本文介绍了如何在JavaFX 2.0中更改插入符颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望将项目从Swing迁移到JavaFX作为新的UI技术。作为我们公司设计的一部分,我们将Swing中的插入符号颜色更改为浅绿色。

We want to migrate a project from Swing to JavaFX as the new UI technology. As a part of our corporate design, we were changing the caret color in Swing to a light green.

我们如何改变JavaFX 2.0中插入符号的颜色(或者其他外观)?我找不到任何有用的信息。我看到它在早期版本的JavaFX中是可能的,所以我想在2.0中也有一种方法。

How can we alter the color(or maybe also other things about the appearance) of carets in JavaFX 2.0? I couldn't find any useful information about it. I saw that it was possible in earlier versions of JavaFX, so i guess there's a way in 2.0 too.

亲切的问候,

David

推荐答案

在TextField中,插入符号与文本颜色相同。你可以改变它们:

In the TextField caret has the same color as text. You can change them by:

    TextField tf = new TextField("Text");
    tf.setStyle("  -fx-text-fill: green");

或css文件中的全局。

or globally in css file.

这篇关于如何在JavaFX 2.0中更改插入符颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆