난 테이블 크기가 CONSTRAINED_RESIZE_POLICY 열 크기 조정 정책이 있습니다. 창을 수동으로 크기를 조정하면 좋지만 최대화 또는 최대화 상태에서 복원하면 열이 조정되지 않습니다.TableView 항상 열의 크기를 조정하지 않습니다
이러한 경우 열의 크기를 조정할 수 있도록 TableView에서 강제로 "새로 고침"할 수있는 방법이 있습니까?
UPDATE : 샘플 컴파일 가능한 코드가 크기 조정 정책에 따라 문제
public class TableViewResizeTest extends Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("TableView resize demo");
ObservableList<Room> roomsList = FXCollections.observableArrayList();
final TableView rooms = new TableView();
TableColumn icons = new TableColumn();
TableColumn name = new TableColumn("Name");
TableColumn topic = new TableColumn("Topic");
TableColumn users = new TableColumn("Users");
rooms.getColumns().addAll(icons, name, topic, users);
name.setCellValueFactory(new PropertyValueFactory<Room,String>("name"));
topic.setCellValueFactory(new PropertyValueFactory<Room,String>("topic"));
users.setCellValueFactory(new PropertyValueFactory<Room,String>("users"));
icons.setCellValueFactory(new PropertyValueFactory<Room,String>("icons"));
name.setMinWidth(50);
name.setMaxWidth(450);
topic.setMinWidth(10);
users.setMinWidth(100);
users.setMaxWidth(150);
icons.setMaxWidth(35);
icons.setMinWidth(35);
// Room resize policy, this is almost perfect
rooms.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
for (int i = 1; i<50; i++) roomsList.add(new Room("Sample Room "+i));
rooms.setItems(roomsList);
BorderPane root = new BorderPane();
root.setCenter(rooms);
primaryStage.setScene(new Scene(root, 500, 460));
primaryStage.show();
}
public class Room {
public Room(String name) {
this.name = new SimpleStringProperty(name);
this.topic= new SimpleStringProperty("This is a sample description text");
this.icon= new SimpleStringProperty("");
nUsers = (int)(Math.random()*1000);
this.users= new SimpleStringProperty(nUsers.toString());
}
Integer nUsers;
private SimpleStringProperty name;
private SimpleStringProperty topic;
private SimpleStringProperty users;
private SimpleStringProperty icon;
public String getName() {
return name.get();
}
public void setName(String name) {
this.name.set(name);
}
public String getTopic() {
return topic.get();
}
public void setTopic(String topic) {
this.topic.set(topic);
}
public String getUsers() {
return nUsers.toString();
}
public void setUsers(String users) {
this.users.set(users);
}
public String getIcon() {
return icon.get();
}
public void setIcon(String icon) {
this.icon.set(icon);
}
}
}
를 재현하기 위해, 마지막 열은 "사용자"항상 볼 수 있어야합니다, 당신은 수동으로 폼의 크기를 조정할 경우 작동 벌금. 그러나 최대화 및 복원을 몇 번 시도하면 창 크기를 수동으로 약간 조정할 때까지 뷰가 해제된다는 것을 알 수 있습니다.
데모 코드를 첨부 해주십시오. 나는 나 자신과 노력했고 그 시나리오를 관찰 할 수 없었다. 또한 환경을 제공하십시오. javafx 버전, os 등. –
샘플 코드를 추가했는데 내 환경은 JavaFx 2.1, Windows 7에서 실행되는 Netbeans 7.1.2입니다. Javafx 개선에 관심을 가져 주셔서 대단히 감사합니다. 나는 매우 감명 받았다. – betaman
문제가 해결 될 때까지 BTW, 해결 방법, TableView "새로 고침"하는 방법을 많이 주시면 감사하겠습니다. – betaman