欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

javaFX笔记----ComboBox模仿qq账号下拉框删除账号

程序员文章站 2022-07-11 09:21:59
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;
            }
                    
    });






javaFX笔记----ComboBox模仿qq账号下拉框删除账号