I've developed a simple custom TableCell to enable the edition of the values in a table. The behaviour of the component is show a BigDecimalTextField no matter if the user is editing or not that cell, it should enable the edition all the time. The component is working fine, there is only a strange problem: when the table is rendered, instead of show only a single line, three lines are shown:
The code of the component is this:
public class BigDecimalEditingCell extends TableCell {
private BigDecimalField spinner = new BigDecimalField(new BigDecimal("0.00"));
private ObjectProperty<BigDecimal> campoLigado = null;
public BigDecimalEditingCell() {
this.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
createField();
}
private void createField() {
spinner.setStepwidth(new BigDecimal("0.01"));
spinner.setMinValue(new BigDecimal("0.00"));
spinner.setFormat(NumberFormat.getInstance());
spinner.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
}
#Override
public void updateItem(Object item, boolean empty) {
super.updateItem(item, empty);
criarBind();
setGraphic(spinner);
setText(null);
}
private void criarBind() {
ObservableValue<BigDecimal> valor = getTableColumn().getCellObservableValue(getIndex());
if (valor != null) {
ObjectProperty<BigDecimal> propriedade = (ObjectProperty<BigDecimal>) valor;
if (campoLigado == null) {
spinner.numberProperty().bindBidirectional(propriedade);
campoLigado = propriedade;
} else if (campoLigado != propriedade) {
spinner.numberProperty().unbindBidirectional(campoLigado);
spinner.numberProperty().bindBidirectional(propriedade);
campoLigado = propriedade;
}
}
}
}
If I use the default TextFieldTableCell, the table is rendered correctly. I have another component (like this) that uses JavaFX's DatePicker and the same problem happens.
What I'm doing wrong?
ADDED
Here is the usage of this component:
public class ControladorPainelFormaPagamento extends ControladorPainelSubmeter {
#FXML
private TableView<ParcelaBean> tabela;
#FXML
private TableColumn<ParcelaBean, LocalDate> colunaVencimento;
#FXML
private TableColumn<ParcelaBean, BigDecimal> colunaValor;
private FormaPagamentoBean bean;
.
.
.
private void configurarColunaValor() {
colunaValor.setCellValueFactory(new PropertyValueFactory<ParcelaBean, BigDecimal>("valor"));
colunaValor.setCellFactory(new Callback<TableColumn<ParcelaBean, BigDecimal>, TableCell<ParcelaBean, BigDecimal>>() {
#Override
public TableCell<ParcelaBean, BigDecimal> call(TableColumn<ParcelaBean, BigDecimal> parcelaBeanStringTableColumn) {
return new BigDecimalEditingCell();
}
});
}
private void configurarColunaVencimento() {
colunaVencimento.setCellValueFactory(new PropertyValueFactory<ParcelaBean, LocalDate>("dataVencimento"));
}
public void carregar(ModoExibicao modoExibicao, FormaPagamentoBean formaPagamento) {
this.bean=formaPagamento;
tabela.setItems(bean.getParcelas());
.
.
.
}
.
.
.
}
I've checked, inclusive using debug, if there was more than one bean in the list used by the table. Every time only one was there.
I was looking at another table in the same system and noticed this: when there is no item in the table, no one row is rendered.
but when you add just one row, the table renders empty row until reach the height of the table (repair the light grey rows):
So, it was obvious that the extra rows were added by TableView, this way a simple null check solve the problem:
public class BigDecimalEditingCell extends TableCell {
private BigDecimalField element = new BigDecimalField(new BigDecimal("0.00"));
private ObjectProperty<BigDecimal> campoLigado = null;
#Override
protected void updateItem(Object item, boolean empty) {
super.updateItem(item,empty);
if (getIndex() < getTableView().getItems().size() && !empty) {
createField();
createBind();
setGraphic(element);
setText(null);
} else {
removeBind();
setGraphic(null);
}
}
.
.
.
}
Related
In one of our applications we use the lazy query container to browse a potentially very large dataset. This works great. However, it is possible to select an arbitrary number of rows when using a multi-select table.
In our case, this can lead to selecting up to 500.000 rows (Vaadin limit) and then crash the VM.
Is there a way to limit the number of selected rows?
Here is a sample that shows the problem:
public class UIImpl extends UI {
private int SIZE = 500000;
#Override
protected void init(VaadinRequest request) {
// add a large table
LazyQueryContainer lqc = new LazyQueryContainer(
new QueryFactory() {
public Query constructQuery(QueryDefinition qd) {
return new Query() {
#Override
public int size() {
return SIZE;
}
#Override
public void saveItems(List<Item> addedItems, List<Item> modifiedItems, List<Item> removedItems) { }
#Override
public List<Item> loadItems(int startIndex, int count) {
List<Item> r = new ArrayList<>(count);
for (int i = startIndex; i<startIndex+count;i++) {
PropertysetItem item = new PropertysetItem();
item.addItemProperty("name", new ObjectProperty(i));
r.add(item);
}
return r;
}
#Override
public boolean deleteAllItems() {
return false;
}
#Override
public Item constructItem() {
return null;
}
};
}
},
null,
20,
false
);
lqc.addContainerProperty("name", Integer.class, null);
Table table = new Table();
table.setContainerDataSource(lqc);
table.setMultiSelect(true);
table.setSelectable(true);
table.setImmediate(true);
table.setVisibleColumns("name");
table.setSizeFull();
table.addValueChangeListener(new Property.ValueChangeListener() {
public void valueChange(Property.ValueChangeEvent event) {
System.err.println(event.getProperty().getValue());
}
});
setContent(table);
}
}
If you want to limit the number of rows a user is able to select you can use something similar to the following code:
public class TableWithSelectionLimit extends Table {
private final int maxSelections= -1;
private String[] lastSelected;
public TableWithSelectionLimit(int maxSelections) {
this.maxSelections = maxSelections;
}
#Override
public void changeVariables(Object source, Map<String, Object> variables) {
String[] selected = (String[]) variables.get("selected");
if (selected != null && selected.length > maxSelections) {
if (lastSelected != null) {
variables.put("selected", lastSelected);
} else {
variables.remove("selected");
}
markAsDirty();
} else {
lastSelected = selected;
}
super.changeVariables(source, variables);
}
}
This is of course optimizable, but it gives you an idea on how you could do it.
Update
For handling also selections produced using "Shift"+Click one has to handle/update these selection ranges additionally inside the method mentioned above.
Those can be retrieved using variables.get("selectedRanges") that will return a String[] containing items like "8-10" whereas the
first number is: the start index of the selection range
second number is: the amount of items selected starting at this index
Using this information it should be possible to update those values as wished and put them back into the variables using variables.put("selectedRanges", updatedRanges).
Attention: do not forget to call markAsDirty() if the values are changed, as otherwise the changes won't be propagated to the client side.
I've got a project written in JavaFX and I'm trying to get a refresh on a tableview without result.
I've googled around and tried some examples I've found but it still doesn't work.
I populate a tableview with information each row in this table can have new comments added to by double click on the row. The a new Tabpane is opened and the new comment can be added there. On close of this tabpane I'd like the one I clicked from to be refreshed.
I must be doing something wrong. I just don't know what.
In my StoreController
private void populateTableView(List<Store> stores) {
ObservableList<Store> data = FXCollections.observableArrayList(stores);
storeNumberColumn.setCellValueFactory(
new PropertyValueFactory<Store, String>("id"));
storePhoneColumn.setCellValueFactory(
new PropertyValueFactory<Store, String>("phoneNbr"));
chainColumn.setCellValueFactory(
new PropertyValueFactory<Store, String>("chainId"));
commentColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Store, ImageView>, ObservableValue<String>>() {
#Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<Store, ImageView> p) {
Integer numberOfComments = p.getValue().getCommentsCount();
ReadOnlyObjectWrapper wrapper = null;
if (numberOfComments == 0) {
wrapper = null;
} else if (numberOfComments == 1) {
wrapper = new ReadOnlyObjectWrapper(new ImageView(COMMENT_SINGLE_FLAG_SOURCE));
} else {
wrapper = new ReadOnlyObjectWrapper(new ImageView(COMMENT_DOUBLE_FLAG_SOURCE));
}
return wrapper;
}
});
storeTable.setItems(data);
sortTable(storeTable, missedColumn);
}
#FXML
public void handleTableAction(MouseEvent event) {
if (event.getClickCount() == 2) {
showNewCommentStage();
}
}
private void showNewCommentStage() {
initCommentController();
Store store
= storeTable.getSelectionModel().selectedItemProperty().getValue();
commentController.showNewStage(commentPane, store);
}
It seems like the call-function doesn't get called when the commentpane is closed.
CommentController
public void showNewStage(Pane pane, Store store) {
this.store = store;
initStage(pane);
windowHandler = new WindowHandler(stage);
effectHandler.playEffect(pane);
constructCommentHeaders();
List<Comment> comments;
comments = commentService.listByStoreId(store.getId());
populateCommentTable(comments);
}
Like I said I've tried a lot of the solutions found here on Stackoverflow but with no results. The Tableview doesn't refresh. The Stores and the Comments are in different database tables if that's important
Can someone point me in the right direction?
Thanks!
****EDIT****
The Store.class
public class Store extends CommentEntity {
private String id;
private String chainId;
private String phoneNbr;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getChainId() {
return chainId;
}
public void setChainId(String chainId) {
this.chainId = chainId;
}
public String getPhoneNbr() {
return phoneNbr;
}
public void setPhoneNbr(String phoneNbr) {
this.phoneNbr = phoneNbr;
}
#Override
public String toString() {
return "Store{" + "id=" + id + ", chainId=" + chainId + '}';
}
#Override
public String getCommentIdentifier() {
return id;
}
}
The CommentEntity.Class
public abstract class CommentEntity {
private int commentsCount;
public int getCommentsCount() {
return commentsCount;
}
public void setCommentsCount(int commentsCount) {
this.commentsCount = commentsCount;
}
public abstract String getCommentIdentifier();
}
Thank you for input, I hadn't even reflected over the ImageView / String.
Two issues:
First, you need to distinguish between the data the cells in your column are displaying, and the cells that actually display those data. The cellValueFactory determines the data that are displayed. The PropertyValueFactory is a cellValueFactory implementation that references a JavaFX Property, so when you call
storeNumberColumn.setCellValueFactory(new PropertyValueFactory<Store, String>("id"));
it effectively tells the cells in the storeNumberColumn to call the idProperty() method on the Store object in the current row to get the data for the cell. (If no such method exists, it will try to use getId() as a backup plan.)
By default, you get a cellFactory that displays text resulting from calling toString() on the data generated by the cellValueFactory. In the case where your data are simply Strings, this is usually what you need. In other cases, you often need to provide a cellFactory of your own to get the correct way to display the data.
In your case, the data for the commentColumn are simply the number of comments. You are going to display that by choosing an image based on that numeric value.
So you should have
TableColumn<Store, Number> commentColumn = new TableColumn<>("Comments");
For the cellValueFactory, you can just use
commentColumn.setCellValueFactory(new PropertyValueFactory<>("commentsCount"));
Then you need a cellFactory that displays the appropriate ImageView:
commentColumn.setCellFactory(new Callback<TableColumn<Store, Number>, new TableCell<Store, Number>>() {
#Override
public TableCell<Store, Number>() {
private ImageView imageView = new ImageView();
#Override
public void updateItem(Number numberOfComments, boolean empty) {
super.updateItem(count, empty) ;
if (empty) {
setGraphic(null);
} else {
if (numberOfComments.intValue() == 0) {
setGraphic(null);
} else if (numberOfComments.intValue() == 1) {
imageView.setImage(new Image(COMMENT_SINGLE_FLAG_SOURCE));
setGraphic(imageView);
} else {
imageView.setImage(new Image(COMMENT_DOUBLE_FLAG_SOURCE));
setGraphic(imageView);
}
}
}
}
});
The second issue is actually about the update. A TableView keeps its contents "live" by observing JavaFX properties that are provided by the cellValueFactory as ObservableValues. If the value might change while the table is displayed, you must provide an actual property that can be observed: using a ReadOnlyObjectWrapper is no good (because it's read only, so it's wrapped value will not change). The PropertyValueFactory will also return a ReadOnlyObjectWrapper if you do not have JavaFX property accessor methods (i.e. if it is only using getXXX() methods to access the data). So your model class must provide JavaFX Properties.
You can make an immediate fix to this by updating CommentEntity to use an IntegerProperty:
public abstract class CommentEntity {
private final IntegerProperty commentsCount = new SimpleIntegerProperty();
public final int getCommentsCount() {
return commentsCountProperty().get();
}
public final void setCommentsCount(int commentsCount) {
commentsCountProperty().set(commentsCount);
}
public IntegerProperty commensCountProperty() {
return commentsCount ;
}
public abstract String getCommentIdentifier();
}
I would also strongly recommend updating the Store class to use JavaFX Properties in a similar manner.
Trying to make my CellTable Colum sortable but I'm not getting it to work. I'm having an MVP application which gets data from a rest service. To show the data within the table works fine but to sort is doesn't work.
public class LicenseUsageUserViewImpl<T> extends Composite implements LicenseUsageUserView<T> {
#UiTemplate("LicenseUsageUserView.ui.xml")
interface LicenseDataViewUiBinder extends UiBinder<ScrollPanel,LicenseUsageUserViewImpl> {}
private static LicenseDataViewUiBinder uiBinder = GWT.create(LicenseDataViewUiBinder.class);
#UiField
CellTable<GWTLicenseUser> licenseUserCellTable;
List<GWTLicenseUser> licenseUsers;
ListDataProvider<GWTLicenseUser> dataProvider;
public List<GWTLicenseUser> getLicenseUsers() {
return licenseUsers;
}
public void setLicenseUsers(List<GWTLicenseUser> licenseUsers) {
this.licenseUsers = licenseUsers;
}
#UiField Label header;
ListHandler<GWTLicenseUser> sortHandler;
public LicenseUsageUserViewImpl() {
initWidget(uiBinder.createAndBindUi(this));
initCellTable();
}
#Override
public void setLicenseUsersTable(List<GWTLicenseUser> tmpLicenseUsers) {
if (tmpLicenseUsers.isEmpty()) {
licenseUserCellTable.setVisible(false);
} else {
setLicenseUsers(tmpLicenseUsers);
licenseUserCellTable.setWidth("100%");
licenseUserCellTable.setVisible(true);
licenseUserCellTable.setPageSize(getLicenseUsers().size());
licenseUserCellTable.setRowCount(getLicenseUsers().size(), false);
licenseUserCellTable.setRowData(0, getLicenseUsers());
licenseUserCellTable.setVisibleRange(new Range(0, licenseUserCellTable.getRowCount()));
sortHandler.setList(getLicenseUsers());
dataProvider.getList().clear();
dataProvider.getList().addAll(getLicenseUsers());
}
}
#Override
public void initCellTable() {
sortHandler = new ListHandler<GWTLicenseUser>(getLicenseUsers());
licenseUserCellTable.addColumnSortHandler(sortHandler);
licenseUserCellTable.setWidth("100%");
licenseUserCellTable.setVisible(true);
licenseUserCellTable.setVisibleRange(new Range(0, licenseUserCellTable.getRowCount()));
// Create a data provider.
dataProvider = new ListDataProvider<GWTLicenseUser>();
// Connect the table to the data provider.
dataProvider.addDataDisplay(licenseUserCellTable);
licenseUserCellTable.setWidth("100%");
licenseUserCellTable.setAutoHeaderRefreshDisabled(true);
licenseUserCellTable.setAutoFooterRefreshDisabled(true);
// userID
TextColumn<GWTLicenseUser> userIdColumn = new TextColumn<GWTLicenseUser>() {
#Override
public String getValue(GWTLicenseUser object) {
if (object != null ){
return object.getUserId();
} else {
return "NULL";
}
}
};
userIdColumn.setSortable(true);
sortHandler.setComparator(userIdColumn, new Comparator<GWTLicenseUser>() {
#Override
public int compare(GWTLicenseUser o1, GWTLicenseUser o2) {
return o1.getUserId().compareTo(o2.getUserId());
}
});
licenseUserCellTable.addColumn(userIdColumn, "User ID");
// more column entries
licenseUserCellTable.getColumnSortList().push(userIdColumn);
licenseUserCellTable.getColumnSortList().push(countColumn);
licenseUserCellTable.addColumnSortHandler(sortHandler);
}
}
setLicenseUsersTable is called from my activity with the response list of my users. When I start my application and make a rest call my data is provide and put into my list also shown within the CellTable but its not sortable, but I have this sort icon before my colum name. I figured I post the whole code because I think its know easier to see what I'm trying to do.
Thanks for any help.
Remove this line:
sortHandler.setList(getLicenseUsers());
You already passed a List into the SortHandler constructor in
sortHandler = new ListHandler<GWTLicenseUser>(getLicenseUsers());
Also, instead of
setLicenseUsers(tmpLicenseUsers);
you may need to use
licenseUsers.addAll(tmpLicenseUsers);
I hope one of them fixes the problem.
I have a java bean object list which I would like to display in ListView control. By default ListView uses toString method.
How can I define which property to use for rendering in ListView?
I want to achieve same functionality as in TableView can be achieved by PropertyValueFactory in this code:
#FXML
private TableView<Person> mainTableView;
//...
TableColumn<Person,String> personColumn = new TableColumn<>("Name");List
personColumn.setCellValueFactory(new PropertyValueFactory("name"));
mainTableView.getColumns().add(personColumn);
Edit
It looks like there is no easy(out of the box) solution. Based on code from James_D I created generic class to deal with the problem. It wraps PropertyValueFactory - note that PropertyValueFactory firstly looks for method [NAME]Property() trying to get observable, only when it is not found it tries to access standard bean properties.
public class PropertyValueFactoryWrapperCellFactory<T> implements Callback<ListView<T>, ListCell<T>> {
private final PropertyValueFactory<T, String> pvf;
public PropertyValueFactoryWrapperCellFactory(String propertyName) {
super();
pvf = new PropertyValueFactory(propertyName);
}
#Override
public ListCell<T> call(ListView<T> param) {
return new ListCell<T>() {
#Override
public void updateItem(T item, boolean empty) {
super.updateItem(item, empty);
textProperty().unbind();
if (item == null) {
return;
}
TableColumn.CellDataFeatures<T, String> cdf = new TableColumn.CellDataFeatures<>(null, null, item);
textProperty().bind(pvf.call(cdf));
}
};
}
}
Usage:
#FXML
private ListView<Person> mainListView;
//...
mainListView.setCellFactory(new PropertyValueFactoryWrapperCellFactory("name"));
Use a cell factory.
If the property is immutable, it's pretty straightforward:
ListView<MyDataType> listView = new ListView<>();
listView.setCellFactory(new Callback<ListView<MyDataType>, ListCell<MyDataType>>() {
#Override
public ListCell<MyDataType> call(ListView<MyDataType> lv) {
return new ListCell<MyDataType>() {
#Override
public void updateItem(MyDataType item, boolean empty) {
super.updateItem(item, empty);
if (item == null) {
setText(null);
} else {
// assume MyDataType.getSomeProperty() returns a string
setText(item.getSomeProperty());
}
}
};
}
});
If the property can change its value and the list view needs to update dynamically in response to these changes, you need to bind the textProperty of the list cell:
listView.setCellFactory(new Callback<ListView<MyDataType>, ListCell<MyDataType>>() {
#Override
public ListCell<MyDataType> call(ListView<MyDataType> lv) {
return new ListCell<MyDataType>() {
#Override
public void updateItem(MyDataType item, boolean empty) {
super.updateItem(item, empty);
textProperty().unbind();
if (item == null) {
setText(null);
} else {
// assumes MyDataType.someProperty() returns a StringProperty:
textProperty.bind(item.someProperty());
}
}
};
}
});
Binding String Property
This code allows you to choose what JavaFX property is displayed in a ListView. I use an anonymous class inside a lambda to add some clarity to what is happening. In this example:
Display - The underlying object behind the ListView
titleProperty - The JavaFX property to be displayed
listView.setCellFactory(
listview -> {
return new ListCell<Display>() {
#Override
public void updateItem(Display item, boolean empty) {
super.updateItem(item, empty);
textProperty().unbind();
if(item != null)
textProperty().bind(item.titleProperty());
else
setText(null);
}
};
}
);
Explanation
With this code, we are basically making a custom ListCell. When it is updated and the item it is display is null, we clear the display text. Otherwise, we set the text to be whatever the title property of our item is.
TL;DR :: Modified James_D's Solution
I based this on James_D's second example. I wanted to bind a SimpleStringProperty to be the displayed text in a ListView. James_D's solution worked great but didn't update when I deleted an object from the ObservableList in the ListView, so I modified it. I also thought having a cleaner lambda example would be good.
I want to use a custom control (ClientControl in the code) in my TableView. Therefore I created a class ClientCell:
public class NewClientCell extends TableCell<Client, Client> {
private final ClientControl cc;
public NewClientCell(ObservableList<Client> suggestions) {
cc = new ClientControl(this.getItem(), suggestions);
this.setAlignment(Pos.CENTER_LEFT);
this.setGraphic(cc);
this.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
#Override
protected void updateItem(Client c, boolean empty) {
super.updateItem(c, empty);
if(!empty){
setGraphic(cc);
}
}
}
In the main program I use the following code to fill the table:
TableColumn<Client, Client> clmClients = new TableColumn<>("Klient");
clmClients.setCellFactory(new Callback<TableColumn<Client, Client>, TableCell<Client, Client>>() {
#Override
public TableCell<Client, Client> call(TableColumn<Client, Client> p) {
return new NewClientCell(suggestions);
};
});
clmClients.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Client, Client>, ObservableValue<Client>>() {
#Override
public ObservableValue<Client> call(TableColumn.CellDataFeatures<Client, Client> p) {
return new SimpleObjectProperty<Client>(p.getValue());
}
});
getColumns().add(clmClients);
The data in the table comes from an ObservableList and is initialized correct.
My problem now is that the custom control needs an Client-Object which it should get out of the ObservableList, but "this.getItem()" always returns null.
How do I get the Client objects correctly into the custom control?
Thanks!
EDIT
Here's the constructor of ClientControl:
public ClientControl(Client client, ObservableList<Client> suggestions) {
setClient(client);
setSuggestions(suggestions);
FXMLLoader loader = new FXMLLoader(getClass().getResource("ClientControl.fxml"));
loader.setRoot(this);
loader.setController(this);
try {
loader.load();
} catch (IOException e) {
throw new RuntimeException(e);
}
initTextField();
setLabelText(client.toString());
}
The method setClient is a simple setter method (this.client = client;). The variables client and suggestions are this simple defined:
private ObservableList<Client> suggestions;
private Client client;
AFAIK, you should instantiate any controls in the constructor as you did, so that they are only created once (remember that cells get reused for different locations).
But then you need to override one or more of the other methods such as updateItem to get the data from the current item to render.
EDIT
Well, you're assigning the same control without changing it over and over again. Rather than setting the graphics in the updateItem method, set the item property of the client control:
#Override
protected void updateItem(Client c, boolean empty) {
super.updateItem(c, empty);
if(!empty){
cc.setClient(c);
} else {
cc.setClient(null);
}
}
Edit 2
The ClientControl should provide the client item as a property instead of a constructor argument and set it in the updateItem method, not in the constructor.
E.g. something like this (untested!):
private final ObjectProperty<Client> client = new SimpleObjectProperty<>(this, "client");
public final Client getClient(){
return clientProperty().get();
}
public final void setClient(Client client){
clientProperty().set(client);
}
public ObjectProperty<Client> clientProperty(){
return client;
}
And in the constructor: listen for changes of this property to set the labelText etc.
You also might want to provide a constructor without a client argument, as it is not available when you instantiate it in the TableCell constructor.
So I found the solution for my problem. Thank you so much Puce for your help! :-)
Now I set Client via the property like that:
private ObjectProperty<Client> clientProperty = new SimpleObjectProperty<Client>();
Additionally I added a ChangeListener in the constructor of ClientControl:
public ClientControl(ObservableList<Client> suggestions) {
clientProperty.addListener(new ChangeListener<Client>() {
#Override
public void changed(ObservableValue<? extends Client> observable, Client oldValue,
ClientnewValue) {
if(newValue != null) {
setLabelText(newValue.toString());
}
}
});
setSuggestions(suggestions);
FXMLLoader loader = new FXMLLoader(getClass().getResource("ClientControl.fxml"));
loader.setRoot(this);
loader.setController(this);
try {
loader.load();
} catch (IOException e) {
throw new RuntimeException(e);
}
initTextField();
}
My ClientCell class needed only some simple changes because of the changes in ClientControl:
public class NewClientCell extends TableCell<Client, Client> {
private final ClientControl cc;
public NewClientCell(ObservableList<Client> suggestions) {
cc = new ClientControl(suggestions);
this.setAlignment(Pos.CENTER_LEFT);
this.setGraphic(cc);
this.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
#Override
protected void updateItem(Client c, boolean empty) {
super.updateItem(c, empty);
if(!empty){
cc.setClient(c);
}
}
}
In the main program nothing changed.
In conclusion I would like to thank Puce one more time, I stuck at this problem for many days...