-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
8u92
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
Windows 7 x64
A DESCRIPTION OF THE PROBLEM :
I use TableView with multiple cell selection enabled and with fixedCellSize set to a fixed value.
I noticed, that when a user undisplays the rightmost column[s] through the table menu (the little plus in the right upper corner), the cells where the column was, produce strange visual artifacts when selected and selectedCell listener delivers mostly nonsense for them.
See small attached test case, which demonstrates the issue.
The behavior of the test case becomes correct, if I remove the line:
table.setFixedCellSize(24);
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Start the case case
2) open the table menu (little plus in the right upper corner of the table)
3) undisplay the "Col 07"
4) repeat the steps 2-3 for columns "Col 06" and "Col 05"
5) you still can click on the cells, where columns "Col 05" - "Col 07" were and see not an usual blue selection, but tiny blue border instead.
6) check what cell selection listener prints in the console, mostly the events are nonsense: for the first row and non-existent cell it says "[] added at 0", for other rows "something added but nothing removed", although the selection is effectively being replaced (or it were if the cells were valid).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No cell selection (both visual and listener event) for not more existent cells.
ACTUAL -
Not more valid cells become selected appearance (blue frame, as with empty cells), the cell selection listener delivers nonsense.
Ctrl+click does not work for those cells.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package de.lexcom.tableview;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.scene.Scene;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TablePosition;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
public class FXTableViewExample7 extends Application {
public static void main(String [] args) {
Application.launch(args);
}
private TableView<Integer> table;
private final static int NUM_COLUMNS = 8;
@Override
public void start(Stage primaryStage) {
table = new TableView<>();
final Map<Integer, List<StringProperty>> data = new HashMap<>();
for (int i=0; i<20; i++) {
List<StringProperty> row = new ArrayList<>();
for (int j=0; j<NUM_COLUMNS; j++) {
row.add(new SimpleStringProperty(String.format("%02d-%02d", i, j)));
}
data.put(i, row);
}
table.setItems(FXCollections.observableArrayList(data.keySet()));
for (int j=0; j<NUM_COLUMNS; j++) {
final int _j = j;
TableColumn<Integer, String> col = new TableColumn<Integer, String>(String.format("Col %02d", j)) {
@Override
public String toString() {
return String.format("column{%02d}", _j);
}
};
col.setCellValueFactory(feat -> data.get(feat.getValue()).get(_j));
table.getColumns().add(col);
}
table.setEditable(false);
table.setTableMenuButtonVisible(true);
table.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY);
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
table.getSelectionModel().setCellSelectionEnabled(true);
table.setFixedCellSize(24);
table.getSelectionModel().getSelectedCells().addListener((ListChangeListener.Change<? extends TablePosition> change) -> {
while (change.next()) {
System.out.println(String.format("selection change: %s", change));
}
});
Scene scene = new Scene(table, 500, 475);
primaryStage.setScene(scene);
primaryStage.show();
}
}
---------- END SOURCE ----------
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
Windows 7 x64
A DESCRIPTION OF THE PROBLEM :
I use TableView with multiple cell selection enabled and with fixedCellSize set to a fixed value.
I noticed, that when a user undisplays the rightmost column[s] through the table menu (the little plus in the right upper corner), the cells where the column was, produce strange visual artifacts when selected and selectedCell listener delivers mostly nonsense for them.
See small attached test case, which demonstrates the issue.
The behavior of the test case becomes correct, if I remove the line:
table.setFixedCellSize(24);
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Start the case case
2) open the table menu (little plus in the right upper corner of the table)
3) undisplay the "Col 07"
4) repeat the steps 2-3 for columns "Col 06" and "Col 05"
5) you still can click on the cells, where columns "Col 05" - "Col 07" were and see not an usual blue selection, but tiny blue border instead.
6) check what cell selection listener prints in the console, mostly the events are nonsense: for the first row and non-existent cell it says "[] added at 0", for other rows "something added but nothing removed", although the selection is effectively being replaced (or it were if the cells were valid).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No cell selection (both visual and listener event) for not more existent cells.
ACTUAL -
Not more valid cells become selected appearance (blue frame, as with empty cells), the cell selection listener delivers nonsense.
Ctrl+click does not work for those cells.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package de.lexcom.tableview;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.scene.Scene;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TablePosition;
import javafx.scene.control.TableView;
import javafx.stage.Stage;
public class FXTableViewExample7 extends Application {
public static void main(String [] args) {
Application.launch(args);
}
private TableView<Integer> table;
private final static int NUM_COLUMNS = 8;
@Override
public void start(Stage primaryStage) {
table = new TableView<>();
final Map<Integer, List<StringProperty>> data = new HashMap<>();
for (int i=0; i<20; i++) {
List<StringProperty> row = new ArrayList<>();
for (int j=0; j<NUM_COLUMNS; j++) {
row.add(new SimpleStringProperty(String.format("%02d-%02d", i, j)));
}
data.put(i, row);
}
table.setItems(FXCollections.observableArrayList(data.keySet()));
for (int j=0; j<NUM_COLUMNS; j++) {
final int _j = j;
TableColumn<Integer, String> col = new TableColumn<Integer, String>(String.format("Col %02d", j)) {
@Override
public String toString() {
return String.format("column{%02d}", _j);
}
};
col.setCellValueFactory(feat -> data.get(feat.getValue()).get(_j));
table.getColumns().add(col);
}
table.setEditable(false);
table.setTableMenuButtonVisible(true);
table.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY);
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
table.getSelectionModel().setCellSelectionEnabled(true);
table.setFixedCellSize(24);
table.getSelectionModel().getSelectedCells().addListener((ListChangeListener.Change<? extends TablePosition> change) -> {
while (change.next()) {
System.out.println(String.format("selection change: %s", change));
}
});
Scene scene = new Scene(table, 500, 475);
primaryStage.setScene(scene);
primaryStage.show();
}
}
---------- END SOURCE ----------