public class EffectTest extends Application {
public static void main(String[] args) {
launch(args);
} @Override
public void start(Stage stage) {
stage.setTitle("ComboBoxSample");
Scene scene = new Scene(new Group(), , ); ComboBox emailComboBox = new ComboBox();
emailComboBox.getItems().addAll("A","B","C","D","E"); emailComboBox.setPromptText("Email address");
emailComboBox.setEditable(true);
emailComboBox.valueProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue ov, String t, String t1) {
System.out.println(ov);
System.out.println(t);
System.out.println(t1);
}
}); emailComboBox.setCellFactory(
new Callback<ListView<String>, ListCell<String>>() {
@Override public ListCell<String> call(ListView<String> param) {
final ListCell<String> cell = new ListCell<String>() {
{
super.setPrefWidth();
}
@Override public void updateItem(String item,
boolean empty) {
super.updateItem(item, empty);
if (item != null) {
setText(item);
if (item.contains("A")) {
setTextFill(Color.RED);
}
else if (item.contains("B")){
setTextFill(Color.GREEN);
}
else {
setTextFill(Color.BLACK);
}
}
else {
setText(null);
}
}
};
return cell;
} }); GridPane grid = new GridPane();
grid.setVgap();
grid.setHgap();
grid.setPadding(new Insets(, , , ));
grid.add(new Label("To: "), , );
grid.add(emailComboBox, , ); Group root = (Group) scene.getRoot();
root.getChildren().add(grid);
stage.setScene(scene);
stage.show(); } }

javafx ComboBox Event and change cell color的更多相关文章

  1. change the color of a disabled TEdit?

    change the color of a disabled TEdit? Author: P. Below Category: VCL {Question:How can I change the  ...

  2. js & input event & input change event

    js & input event & input change event vue & search & input change <input @click=& ...

  3. WPF standard ComboBox Items Source Change Issue

    Today I encountered an issue with the WPF standard CombBox where if the bound ItemsSource (collectio ...

  4. JavaFX ComboBox的选中事项

    参考1:https://blog.csdn.net/mexel310/article/details/37909205 参考2:https://blog.csdn.net/maosijunzi/art ...

  5. highcharts dynamic change line color

    mouseOut: function(){ this.series.graph.attr({"stroke","#ccc"}) }

  6. Change the color of a link in an NSMutableAttributedString

    Swift Updated for Swift 3 Use with a textView.linkTextAttributes = [NSForegroundColorAttributeName: ...

  7. 颜色选择器 rgb 与16进制 颜色转换

    1. h5 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  8. mplayer-for-windows change color scheme in win 7

    Q: When I play movie on Windows7, always comes this message: The color scheme has been changed The f ...

  9. How to change the text color in the terminal

    You can open the file ~/.bashrc and then choose the force_color_prompt=yes otherwise, you can change ...

随机推荐

  1. null, undefined理解

    概述 null与undefined都可以表示"没有",含义非常相似.将一个变量赋值为undefined或null,语法效果几乎没区别. var a = undefined; // ...

  2. NodeJS学习笔记 (22)全局对象-global

    https://github.com/chyingp/nodejs-learning-guide

  3. bzoj1612 Usaco08 Jan 牛大赛

    水题模拟 建一个图,每两个牛进行比赛就连一条边,然后两遍dfs求出比他弱和比他强的牛,最后如果相加数量等于n,说明他能与全部的牛进行比较,排名确定. #include<bits/stdc++.h ...

  4. [洛谷P2394]yyy loves Chemistry I

    题目大意:给你一个实数x($0<x\leq 1$),要你求x/23的值(保留8位小数). 解题思路:此题用double读的精度是不够的,用long double直接读入也会WA,正确做法是“sc ...

  5. Winscp远程连接Linux主机,上传和下载文件

    1.安装Winscp.这里不再赘述,网上搜索下载安装就可以 2.点击桌面Winscp快捷键,打开Winscp 3.在打开的页面上填写远程主机的IP,用户名和密码,点击保存,会在页面的左边出现一个站点, ...

  6. Test-我喜欢LInux

    测试发帖流程 哈哈 习惯一下先.

  7. Win10+TensorFlow-gpu pip方式安装,anaconda方式安装

    中文官网安装教程:https://www.tensorflow.org/install/install_windows#determine_how_to_install_tensorflow 1.安装 ...

  8. Redis报错 : (error) NOAUTH Authentication required.

    原文:Redis报错 : (error) NOAUTH Authentication required. 这个错误是因为没有用密码登陆认证 , 先输入密码试试 . 127.0.0.1:6379> ...

  9. html5缓存

    HTML5 提供了两种在client存储数据的新方法: localStorage - 没有时间限制的数据存储 sessionStorage - 针对一个 session 的数据存储 这些都是由 coo ...

  10. 9.ng-options

    转自:https://www.cnblogs.com/best/tag/Angular/ 该指令允许你基于一个迭代表达式添加选项 <select ng-model="color&quo ...