javafx ComboBox Event and change cell color
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的更多相关文章
- 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 ...
- js & input event & input change event
js & input event & input change event vue & search & input change <input @click=& ...
- WPF standard ComboBox Items Source Change Issue
Today I encountered an issue with the WPF standard CombBox where if the bound ItemsSource (collectio ...
- JavaFX ComboBox的选中事项
参考1:https://blog.csdn.net/mexel310/article/details/37909205 参考2:https://blog.csdn.net/maosijunzi/art ...
- highcharts dynamic change line color
mouseOut: function(){ this.series.graph.attr({"stroke","#ccc"}) }
- Change the color of a link in an NSMutableAttributedString
Swift Updated for Swift 3 Use with a textView.linkTextAttributes = [NSForegroundColorAttributeName: ...
- 颜色选择器 rgb 与16进制 颜色转换
1. h5 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- 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 ...
- 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 ...
随机推荐
- angular route 与 django urls 冲突怎么解决?
app.js var app = angular.module('app', [ 'ngResource', 'ngRoute', // 'ui.bootstrap', // 'ngResource' ...
- js数组的操作 Full
js数组的操作 用 js有很久了,但都没有深究过js的数组形式.偶尔用用也就是简单的string.split(char).这段时间做的一个项目,用到数组的地方很多,自以为js高手的自己居然无从下手,一 ...
- CSS命令
border-bottom-right-radius: 10px;/* 文本框的角的弯曲度*/ border-bottom-left-radius: 10px; border-top-left-rad ...
- HDU-1023 Train Problem II 卡特兰数(结合高精度乘除)
题目链接:https://cn.vjudge.net/problem/HDU-1023 题意 卡特兰数的应用之一 求一个长度为n的序列通过栈后的结果序列有几种 思路 一开始不知道什么是卡特兰数,猜测是 ...
- 通过浏览器地址进行 post get 请求
首先安装curl 1.post chcp 65001 title 接口测试脚本 d: cd D:\curl\ curl -l -X POST -d "params" url ech ...
- HDFS 断点续传,写文件功能
实际上这是个 HDFS 的工具类部分代码. 首先 public static Configuration configuration = null;public static FileSystem f ...
- ArcGIS api for javascript——设置自定义范围和空间参考
描述 这个示例展示了在创建地图时如果定义一个自定义的范围和空间参考. 在 ArcGIS JavaScript API的1.0和1.1版本,任何要使用的地图服务图层都需要和地图的空间参考一致.1.2版本 ...
- CoAP与物联网系统
CoAP简单介绍 引自维基百科上的介绍,用的是谷歌翻译... 受约束的应用协议(COAP)是一种软件协议旨在以很easy的电子设备.使他们能够在互联网上进行交互式通信中使用. 它特别针对小型低功率传感 ...
- vue9 计算属性 computed
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- js插件---强大的图片裁剪Cropper
js插件---强大的图片裁剪Cropper 一.总结 一句话总结:官网或者github里面的文档或者demo才是真的详细 使用的话找到图片裁剪后的base64数据,然后这个数据可下载可传递到服务器 1 ...