javaFX笔记----ComboBox模仿qq账号下拉框删除账号
程序员文章站
2022-04-08 17:51:10
myComboBox.setCellFactory( new Callback, ListCell>() { @Override public ListCell call(ListView param) { // TODO Auto-generated method stub ... ......
mycombobox.setcellfactory( new callback<listview<string>, listcell<string>>() { @override public listcell<string> call(listview<string> param) { // todo auto-generated method stub final listcell<string> cell=new listcell<string>(){ public void updateitem(string item, boolean empty) { super.updateitem(item, empty); this.settext(null); this.setgraphic(null); if (!empty) { button b=new button("x"); this.setgraphic(b); this.settext(item); b.setonmousereleased(new eventhandler<event>() { @override public void handle(event event) { // todo auto-generated method stub system.out.println(mycombobox.getitems().remove(item)); system.out.println("i:"+item); } }); } } }; return cell; } });