Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8123497

Resizable pointer, while there is no resizable component.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • javafx
    • 8.0b104

      Run the application

      import com.sun.javafx.runtime.VersionInfo;
      import javafx.application.Application;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.value.ObservableValue;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TreeItem;
      import javafx.scene.control.TreeTableColumn;
      import javafx.scene.control.TreeTableView;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;
      import javafx.util.Callback;

      public class TreeTableSample1 extends Application {

          TreeTableView<Person> treeTableView;
          TreeTableColumn<Person, String> firstNameCol;

          @Override
          public void start(Stage primaryStage) {

              initTreeTableView();

              HBox root = new HBox(10.0);
              root.getChildren().add(treeTableView);

              Button action = new Button("Increase min width");
              action.setOnAction(new EventHandler<ActionEvent>() {

                  @Override
                  public void handle(ActionEvent actionEvent) {
                      System.out.println("Setting min width to 500");
                      firstNameCol.setMinWidth(500);
                  }
              });

              VBox vb = new VBox(10.0);
              vb.getChildren().add(action);

              root.getChildren().add(vb);

              Scene scene = new Scene(root, 400, 300);

              primaryStage.setTitle(VersionInfo.getRuntimeVersion());
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }

          private void initTreeTableView() {
              treeTableView = new TreeTableView<Person>();
              treeTableView.setMinSize(200, 150);
              treeTableView.setPrefSize(200, 200);
              treeTableView.setMaxSize(200, 250);
              treeTableView.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);

              TreeItem<Person> root = new TreeItem<Person>(new Person("Anna"));
              root.setExpanded(true);
              treeTableView.setRoot(root);
              treeTableView.showRootProperty().set(true);

              firstNameCol = new TreeTableColumn<Person, String>("First name");
              firstNameCol.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<Person, String>, ObservableValue<String>>() {
                  @Override
                  public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<Person, String> p) {
                      return p.getValue().getValue().firstName;
                  }
              });
              firstNameCol.setMinWidth(80d);

              treeTableView.getColumns().addAll(firstNameCol);

              Person p = new Person("Bob");
              treeTableView.getRoot().getChildren().add(new TreeItem<Person>(p));

              p = new Person("Cindy");
              treeTableView.getRoot().getChildren().add(new TreeItem<Person>(p));

              p = new Person("Zack");
              treeTableView.getRoot().getChildren().add(new TreeItem<Person>(p));
          }

          class Person implements Comparable{

              public final SimpleStringProperty firstName;

              public Person(String name) {
                  this.firstName = new SimpleStringProperty(name);
              }

              public String toString() {
                  return firstName.get();
              }

              @Override
              public int compareTo(Object o) {
                  return this.firstName.get().compareTo(((Person) o).firstName.get());
              }
          }
      }

      Click the button.
      Scroll to the right end.
      Move mouse to the right side of the column header.
      You will see mouse looking like "<->" which denotes, that you can resize something. But you cannot resize this column, or anything else.

            jgiles Jonathan Giles
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: