-
Bug
-
Resolution: Won't Fix
-
P4
-
8
-
x86_64
-
generic
FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 16.04 LTS (4.4.0-75-generic)
A DESCRIPTION OF THE PROBLEM :
Column reordering is not working properly if some of the columns are programmatically set to 'not-visible'.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Start the test application. The table columns are printed in the console:
Columns:
First Name
Last Name
E-Mail
Employer
Salary
2. Try to move the first visible column ('Last Name') after the second visible column ('Employer').
You'll notice that nothing happens, but if you take a look at the console you'll notice that the columns are reordered - the 'Last Name' column is moved after the hidden 'E-Mail' column:
Columns:
First Name
E-Mail
Last Name
Employer
Salary
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.test;
import javafx.application.Application;
import javafx.beans.Observable;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class Table extends Application {
public static void main(String[] pArgs) {launch(pArgs);}
public void start(Stage pStage) {
final BorderPane pane = new BorderPane();
final Scene scene = new Scene(pane);
pStage.setScene(scene);
TableView<Person> table = new TableView<Person>();
Person person = new Person();
person.setFirstName("John");
person.setLastName("Snow");
person.setEmail("snow@north");
person.setEmployer("Dragon Queen");
person.setSalary("Kiss");
table.getItems().add(person);
TableColumn<Person,String> firstNameCol = new TableColumn<>("First Name");
firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
TableColumn<Person,String> lastNameCol = new TableColumn<>("Last Name");
lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
TableColumn<Person,String> emailCol = new TableColumn<>("E-Mail");
emailCol.setCellValueFactory(new PropertyValueFactory("email"));
TableColumn<Person,String> employerCol = new TableColumn<>("Employer");
employerCol.setCellValueFactory(new PropertyValueFactory("employer"));
TableColumn<Person,String> salaryCol = new TableColumn<>("Salary");
salaryCol.setCellValueFactory(new PropertyValueFactory("salary"));
table.getColumns().addListener((Observable pObs) -> {
System.out.println("Columns:");
for(TableColumn<Person,?> col : table.getColumns()) {
System.out.println(col.getText());
}
System.out.println("");
});
table.getColumns().setAll(firstNameCol, lastNameCol, emailCol, employerCol, salaryCol);
firstNameCol.setVisible(false);
emailCol.setVisible(false);
table.setTableMenuButtonVisible(true);
pane.setCenter(table);
pStage.show();
}
public class Person {
private StringProperty firstName;
public void setFirstName(String value) { firstNameProperty().set(value); }
public String getFirstName() { return firstNameProperty().get(); }
public StringProperty firstNameProperty() {
if (firstName == null) firstName = new SimpleStringProperty(this, "firstName");
return firstName;
}
private StringProperty lastName;
public void setLastName(String value) { lastNameProperty().set(value); }
public String getLastName() { return lastNameProperty().get(); }
public StringProperty lastNameProperty() {
if (lastName == null) lastName = new SimpleStringProperty(this, "lastName");
return lastName;
}
private StringProperty email;
public void setEmail(String value) { emailProperty().set(value); }
public String getEmail() { return emailProperty().get(); }
public StringProperty emailProperty() {
if (email == null) email = new SimpleStringProperty(this, "email");
return email;
}
private StringProperty employer;
public void setEmployer(String value) { employerProperty().set(value); }
public String getEmployer() { return employerProperty().get(); }
public StringProperty employerProperty() {
if (employer == null) employer = new SimpleStringProperty(this, "employer");
return employer;
}
private StringProperty salary;
public void setSalary(String value) { salaryProperty().set(value); }
public String getSalary() { return salaryProperty().get(); }
public StringProperty salaryProperty() {
if (salary == null) salary = new SimpleStringProperty(this, "salary");
return salary;
}
}
}
---------- END SOURCE ----------
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Ubuntu 16.04 LTS (4.4.0-75-generic)
A DESCRIPTION OF THE PROBLEM :
Column reordering is not working properly if some of the columns are programmatically set to 'not-visible'.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Start the test application. The table columns are printed in the console:
Columns:
First Name
Last Name
Employer
Salary
2. Try to move the first visible column ('Last Name') after the second visible column ('Employer').
You'll notice that nothing happens, but if you take a look at the console you'll notice that the columns are reordered - the 'Last Name' column is moved after the hidden 'E-Mail' column:
Columns:
First Name
Last Name
Employer
Salary
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.test;
import javafx.application.Application;
import javafx.beans.Observable;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class Table extends Application {
public static void main(String[] pArgs) {launch(pArgs);}
public void start(Stage pStage) {
final BorderPane pane = new BorderPane();
final Scene scene = new Scene(pane);
pStage.setScene(scene);
TableView<Person> table = new TableView<Person>();
Person person = new Person();
person.setFirstName("John");
person.setLastName("Snow");
person.setEmail("snow@north");
person.setEmployer("Dragon Queen");
person.setSalary("Kiss");
table.getItems().add(person);
TableColumn<Person,String> firstNameCol = new TableColumn<>("First Name");
firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
TableColumn<Person,String> lastNameCol = new TableColumn<>("Last Name");
lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
TableColumn<Person,String> emailCol = new TableColumn<>("E-Mail");
emailCol.setCellValueFactory(new PropertyValueFactory("email"));
TableColumn<Person,String> employerCol = new TableColumn<>("Employer");
employerCol.setCellValueFactory(new PropertyValueFactory("employer"));
TableColumn<Person,String> salaryCol = new TableColumn<>("Salary");
salaryCol.setCellValueFactory(new PropertyValueFactory("salary"));
table.getColumns().addListener((Observable pObs) -> {
System.out.println("Columns:");
for(TableColumn<Person,?> col : table.getColumns()) {
System.out.println(col.getText());
}
System.out.println("");
});
table.getColumns().setAll(firstNameCol, lastNameCol, emailCol, employerCol, salaryCol);
firstNameCol.setVisible(false);
emailCol.setVisible(false);
table.setTableMenuButtonVisible(true);
pane.setCenter(table);
pStage.show();
}
public class Person {
private StringProperty firstName;
public void setFirstName(String value) { firstNameProperty().set(value); }
public String getFirstName() { return firstNameProperty().get(); }
public StringProperty firstNameProperty() {
if (firstName == null) firstName = new SimpleStringProperty(this, "firstName");
return firstName;
}
private StringProperty lastName;
public void setLastName(String value) { lastNameProperty().set(value); }
public String getLastName() { return lastNameProperty().get(); }
public StringProperty lastNameProperty() {
if (lastName == null) lastName = new SimpleStringProperty(this, "lastName");
return lastName;
}
private StringProperty email;
public void setEmail(String value) { emailProperty().set(value); }
public String getEmail() { return emailProperty().get(); }
public StringProperty emailProperty() {
if (email == null) email = new SimpleStringProperty(this, "email");
return email;
}
private StringProperty employer;
public void setEmployer(String value) { employerProperty().set(value); }
public String getEmployer() { return employerProperty().get(); }
public StringProperty employerProperty() {
if (employer == null) employer = new SimpleStringProperty(this, "employer");
return employer;
}
private StringProperty salary;
public void setSalary(String value) { salaryProperty().set(value); }
public String getSalary() { return salaryProperty().get(); }
public StringProperty salaryProperty() {
if (salary == null) salary = new SimpleStringProperty(this, "salary");
return salary;
}
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8156095 Table view column reordering does not always work when there are hidden columns
-
- Closed
-
-
JDK-8201232 Reordering columns in a TableView by dragging them does not account for invisible columns.
-
- Closed
-