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 ...
随机推荐
- Python中的self(Python笔记)
self Python中类的方法与普通的函数只有一个特别的区别——它们必须有一个额外的第一个参数名称,但是在调用这个方法的时候你不为这个参数赋值,Python会提供这个值.这个特别的变量指对象本身,按 ...
- C++笔试专题一:运算符重载
一:下面重载乘法运算符的函数原型声明中正确的是:(网易2016校招) A:MyClass operator *(double ,MyClass); B:MyClass operator *(MyCla ...
- JAVA-截取字符串两边指定字符
工具类: /** * 工具类 */ public class Tool { /** * 截取两边指定的字符 * @param character * @param symbol * @return * ...
- mybatis-generator-core快速生成实体类和Mapper
日常使用Mybatis少不了和实体类和 Mapper 打交道.除了我们手写来实现,还可以使用 mybatis-generator-core 来快速生成 实体类和 Mapper. 步骤如下: 1.下载 ...
- Linux中常用命令(文件)
1.cat 显示出文件的全部内容 (1)格式:cat 文件名 -n 显示行号 (2)特点:一次性显示所有文件内容 2.tac 从最后一行倒着显示文件全部内容 3.more 全屏方式分页显示文件内容 回 ...
- vue2.0学习教程
十分钟上手-搭建vue开发环境(新手教程)https://www.jianshu.com/p/0c6678671635 如何在本地运行查看github上的开源项目https://www.jianshu ...
- vue14 自定义过滤器
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Long和long判断
Long需要equals 判断. long可以==
- 在spring-mybatis.xml 中配置pagehelper
maven导包:<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</ ...
- BZOJ 1503 treap
思路: treap (算是基本操作吧-..) 加减的操作数很少 就暴力好啦 每回判断一下最小的数是不是比M小 如果是 就删,继续判断 搞定. //By SiriusRen #include <c ...