Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java fx custom cell factory for combo box

@FXML ComboBox<User> cmbUserIds;

Callback<ListView<User>, ListCell<User>> cellFactory = new Callback<ListView<User>, ListCell<User>>() {

    @Override
    public ListCell<User> call(ListView<User> l) {
        return new ListCell<User>() {

            @Override
            protected void updateItem(User item, boolean empty) {
                super.updateItem(item, empty);
                if (item == null || empty) {
                    setGraphic(null);
                } else {
                    setText(item.getId() + "    " + item.getName());
                }
            }
        } ;
    }
}

// Just set the button cell here:
cmbUserIds.setButtonCell(cellFactory.call(null));
cmbUserIds.setCellFactory(cellFactory);
Comment

PREVIOUS NEXT
Code Example
Java :: cannot write data document seems to have been closed already in java 
Java :: springBoot Disable a Specific Auto-Configuration 
Java :: Java Insert Elements to TreeSet 
Java :: java throw exception without method signature 
Java :: convert object address to string in java 
Java :: java ternärer operator 
Java :: get material of block bukkit 
Java :: java pattern matching 
Java :: java output formatting 
Java :: They say that they have to create an instance to their application. What does it mean? 
Java :: read java reader 
Java :: candies price hackerearth solution in java 
Java :: constructor overloading ambiguity resolved 
Java :: java focus to desktop 
Java :: what is abstract class 
Java :: spring component 
Java :: odd numbers in java 
Java :: date to timestamp java 
Java :: string.replace in java 
Java :: what is operator overloading in java 
Java :: java enum values() 
Java :: create thread 
Java :: maven set repository location command line 
Java :: Java Enum ordinal() 
Java :: java forcing user to input int 
Sql :: delete all data in neo4j 
Sql :: sql server 2016 reseed identity 
Sql :: forgot my mysql password mac 
Sql :: mysql alter table add index 
Sql :: postgresql list extensions 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =