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账号下拉框删除账号

 

相关文章:

  • 2021-07-21
  • 2021-11-17
  • 2021-06-02
  • 2021-04-29
  • 2021-12-05
  • 2022-12-23
  • 2021-12-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2021-12-25
  • 2021-04-09
  • 2021-11-26
相关资源
相似解决方案