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

TableView/ListView/TreeView: embedded Label text does not turn white as expected

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: fx2.1
    • Fix Version/s: fx2.1
    • Component/s: javafx
    • Labels:
    • Environment:

      fx2.1 b10
      java 6
      windows 7

      Description

      To reproduce run following code. Click on header in order to table get focus. Select row.

      import javafx.application.Application;
      import javafx.beans.property.SimpleObjectProperty;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.property.StringProperty;
      import javafx.beans.value.ObservableValue;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Node;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.layout.FlowPane;
      import javafx.scene.layout.Pane;
      import javafx.stage.Stage;
      import javafx.util.Callback;


      /**
       *
       * @author javafx
       */
      public class Test extends Application {

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

          private Parent getContent() {
              Pane pane = new FlowPane();

               ObservableList<Person> items = FXCollections.observableArrayList();
              for (int i = 0; i < 10; i++) {
                  items.add(new Person("name " + i, "surname " + i));
              }
              TableColumn<Person, Node> column1 = new TableColumn<Person, Node>("First Name");
              column1.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Person, Node>, ObservableValue<Node>>() {

                  @Override
                  public ObservableValue<Node> call(final TableColumn.CellDataFeatures<Person, Node> p) {
                      SimpleObjectProperty<Node> text = new SimpleObjectProperty<Node>();
                      text.setValue(new Label(p.getValue().getFirstName()));
                      return text;

                  }
              });
              TableColumn<Person, Node> column2 = new TableColumn<Person, Node>("Last Name");
              column2.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Person, Node>, ObservableValue<Node>>() {

                  @Override
                  public ObservableValue<Node> call(final TableColumn.CellDataFeatures<Person, Node> p) {
                      SimpleObjectProperty<Node> text = new SimpleObjectProperty<Node>();
                      text.setValue(new Label(p.getValue().getLastName()));
                      return text;

                  }
              });
              TableView<Person> table = new TableView<Person>(items);
              table.getColumns().setAll(column1, column2);
              table.setPrefHeight(200);
              table.setFocusTraversable(false);

              pane.getChildren().add(table);
              

              return pane;
          }

          public void start(Stage stage) {
              stage.setX(100);
              stage.setY(100);
              stage.setWidth(700);
              stage.setHeight(700);
              Scene scene = new Scene(getContent());
              stage.setScene(scene);
              stage.show();
          }
           public static class Person {

              Person(String firstName, String lastName) {
                  this.firstName = new SimpleStringProperty(firstName);
                  this.lastName = new SimpleStringProperty(lastName);
              }
              public StringProperty firstName;

              public void setFirstName(String value) {
                  firstName.set(value);
              }

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

              public StringProperty firstNameProperty() {
                  if (firstName == null) {
                      firstName = new SimpleStringProperty();
                  }
                  return firstName;
              }
              public StringProperty lastName;

              public void setLastName(String value) {
                  lastName.set(value);
              }

              public String getLastName() {
                  return lastName.get();
              }

              public StringProperty lastNameProperty() {
                  if (lastName == null) {
                      lastName = new SimpleStringProperty();
                  }
                  return lastName;
              }
          }
      }

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              anazarov Andrey Nazarov (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: