2012-03-14 4 views
1

ウィンドウが最大化すると、テーブルビューのサイズが変更されません。 私のプロジェクトではログビューアとしてテーブルを使用していますが、ウィンドウ全体を占有する必要があります。ここ Java FX2.0テーブルビュー

答えて

0

は、変更されたバージョンの状態を最大限にかかわらず、ウィンドウサイズ、ウィンドウ内のすべての利用可能なスペースを占有するようにサイズが変更されますテーブルのいくつかの例のコードなど

import javafx.application.Application; 
import javafx.beans.property.SimpleStringProperty; 
import javafx.collections.FXCollections; 
import javafx.scene.Scene; 
import javafx.scene.control.*; 
import javafx.scene.control.cell.PropertyValueFactory; 
import javafx.scene.layout.StackPane; 
import javafx.stage.Stage; 

public class TableResize extends Application { 
    public static void main(String[] args) { launch(args); } 

    @Override public void start(Stage stage) { 
    TableColumn firstNameCol = new TableColumn("First Name"); 
    firstNameCol.setCellValueFactory(
     new PropertyValueFactory<Person,String>("firstName") 
    ); 
    TableColumn lastNameCol = new TableColumn("Last Name"); 
    lastNameCol.setCellValueFactory(
     new PropertyValueFactory<Person,String>("lastName") 
    ); 

    TableView table = new TableView(); 
    table.getColumns().addAll(firstNameCol, lastNameCol); 
    table.setItems(FXCollections.observableArrayList(
     new Person("Jacob", "Smith"), 
     new Person("Isabella", "Johnson"), 
     new Person("Ethan", "Williams") 
    )); 
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); 

    StackPane layout = new StackPane(); 
    layout.getChildren().add(table); 
    stage.setScene(new Scene(layout)); 
    stage.show(); 
    } 

    public static class Person { 
    private final SimpleStringProperty firstName; 
    private final SimpleStringProperty lastName; 

    private Person(String fName, String lName) { 
     this.firstName = new SimpleStringProperty(fName); 
     this.lastName = new SimpleStringProperty(lName); 
    } 

    public String getFirstName() { return firstName.get(); } 
    public void setFirstName(String fName) { firstName.set(fName); } 
    public String getLastName() { return lastName.get(); } 
    public void setLastName(String fName) { lastName.set(fName); } 
    } 
} 

例ですコードはJavaFX TableView tutorialです。

おそらくresizable layout paneをルートノードとして使用するのではなく、Groupを使用している可能性があります。または、テーブルに適切なcolumn resize policyを設定していない可能性があります。提供されたコードなしであなたのレイアウトの問題が何であるかは言い難いですが、上の例の助けを借りてコードを動かせばうれしいです。

関連する問題