java - 是否可以在java代码中为文本字段设置背景文本?

标签 java css javafx transparent

可以在EditText字段中设置背景文本吗?

    TextField field = new TextField("(*.xml, *.java...)");
    field.setStyle("-fx-prompt-text-fill: transparent;");

在java中? 我不知道这个词,但我想将文本作为模板或在 editText 的背景中使用,例如登录表单等,有什么想法吗?

就像本网站上的搜索字段一样。

最佳答案

你的问题不是很清楚,但我认为你只是要求提示文字?

TextField field = new TextField();
field.setPromptText("(*.xml, *.java...)");

来自documentation :

TextField supports the notion of showing prompt text to the user when there is no text already in the TextField (either via the user, or set programmatically). This is a useful way of informing the user as to what is expected in the text field, without having to resort to tooltips or on-screen labels.

关于java - 是否可以在java代码中为文本字段设置背景文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33614364/

相关文章:

javascript - CSS 过渡结合 JS clickEvent

TextArea 的 JavaFX CSS 样式不起作用

java - 多行 lambda 比较器

javafx - javafx 2.1 中 javafx 1.3 的 javafx.lang 包的替代品是什么?

java - 发现以元素 'simple' 开头的无效内容。 Camel 问题

java - 网络/数据库作业的足够线程数

java - Hibernate 延迟加载 + Jersey REST = 急切加载?

CSS 多列蛇形图案

Java AES密文大小

html - 带有旋转文本的表格单元格的宽度 -- HTML