2 Replies Latest reply on Feb 8, 2013 7:40 AM by Marcello

    ListView.getSelectionModel().select( i) issue

      This might be a minor issue however I spent already too much time on this to figure out:

      Why does the the next item not getting selected, when pressing the button ? It gets focused but I does not get "blue", like it would get when I click on it ??
           final ListView<String> fileList = new ListView<String>();
           ObservableList<String> items =FXCollections.observableArrayList( "111", "222");
           fileList.setItems( items);
           borderPane.setCenter( fileList);
           Button b =new Button();
           b.setOnAction( new EventHandler<ActionEvent>() {
                     public void handle(ActionEvent arg0) {                    
           borderPane.Bottom( b);
      Edited by: Marcello on 07.02.2013 05:58
        • 1. Re: ListView.getSelectionModel().select( i) issue
          Hi. It is not an issue. It works as expected.
          From Caspian.css document:
            /* When the ListView is _not_ focused, we show alternate selection colors */
          .list-cell:filled:selected:focused, .list-cell:filled:selected, .list-view:horizontal .list-cell:filled:selected {
              -fx-background-color: lightgray;
              -fx-text-fill: -fx-selection-bar-text;
          You have 2 options:
          1.     Add fileList.requestFocus() before selection:
                  Button b = new Button();
                  b.setOnAction(new EventHandler<ActionEvent>() {
                      public void handle(ActionEvent arg0) {
          2. Create custom.css fie and override the Caspian.css settings.
          • 2. Re: ListView.getSelectionModel().select( i) issue
            Thanks Shakir,

            This in fact works.