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

TextArea: No scroll bar appeared and NullPointerException happened

    XMLWordPrintable

Details

    Description

      (Win7 + JDK 1.6.0_b27 + javafx_sdk-2_0-fcs-b49-windows-i586-28_sep_2011)

      When running below codes, texts are added to TextArea line by line, but there is no scroll bar appeared.
      (But if you click mouse inside the TextArea, scroll bar will appear immediately)

      And, while the program is still running, click mouse inside the TextArea, and scroll the mouse wheel down
      a few times, NullPointerException happened. (Another thing I realized is, if you even do thing but just wait
      for enough long time, NullPointerException happened as well)

      --- Exception (Sample codes follow) ----
      java.lang.NullPointerException
      at com.sun.javafx.sg.prism.NGText.renderContent(NGText.java:1242)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:188)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:42)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1131)
      at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:205)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:188)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:42)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1131)
      at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:205)
      at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:400)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:188)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:42)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1131)
      at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:205)
      at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:400)
      at com.sun.javafx.sg.prism.NGNode.renderRectClip(NGNode.java:327)
      at com.sun.javafx.sg.prism.NGNode.renderClip(NGNode.java:354)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:180)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:42)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1131)
      at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:205)
      at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:400)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:188)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:42)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1131)
      at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:205)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:188)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:42)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1131)
      at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:205)
      at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:400)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:188)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:42)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1131)
      at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:205)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:188)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:42)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1131)
      at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:205)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:188)
      at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:42)
      at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1131)
      at com.sun.javafx.tk.quantum.PaintRunnable.doPaint(PaintRunnable.java:217)
      at com.sun.javafx.tk.quantum.PaintRunnable.paintImpl(PaintRunnable.java:148)
      at com.sun.javafx.tk.quantum.PaintRunnable.run(PaintRunnable.java:329)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
      at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
      at com.sun.prism.render.RenderJob.run(RenderJob.java:29)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at com.sun.javafx.tk.quantum.QuantumRenderer$ObservedRunnable.run(QuantumRenderer.java:67)
      at java.lang.Thread.run(Thread.java:662)

      ----- Sample codes -----
      /*
       * To change this template, choose Tools | Templates
       * and open the template in the editor.
       */
      package largelistviewissue;
      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.concurrent.Service;
      import javafx.concurrent.Task;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ListView;
      import javafx.scene.control.ProgressBar;
      import javafx.scene.control.TextArea;
      import javafx.scene.text.Font;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;
      /**
       *
       * @author lianqi.li
       */
      public class LargeListViewIssue extends Application {
          java.util.List<java.lang.String> fontNames = Font.getFontNames();
          ObservableList<java.lang.String> listItems = FXCollections.observableArrayList();
          Service s = null;
          Boolean cancelled = false;
          
          @Override public void start(Stage stage) {
              stage.setTitle("TableView Issue");
              final Group root = new Group();
              final Scene scene = new Scene(root, 500, 400);
              
              final ListView<String> listView = new ListView<String>();
              listView.setTranslateX(10);
              listView.setTranslateY(10);
              listView.setPrefHeight(240);

              final TextArea ta = new TextArea();
              ta.setPrefSize(200, 240);
              ta.setTranslateX(240);
              ta.setTranslateY(10);
              
              final Text t = new Text(10, 280, "");
              
              final ProgressBar pb = new ProgressBar(0.0d);
              pb.setPrefWidth(200);
              pb.setTranslateX(240);
              pb.setTranslateY(300);
                      
              final Button bGo = new Button("Go");
              bGo.setLayoutX(10);
              bGo.setLayoutY(300);
              bGo.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent event) {
                      listView.getItems().clear();
                      s = new Service() {
                          @Override protected Task createTask() {
                              return new Task() {
                                  @Override public Void call() throws Exception {
                                      int total = fontNames.size();
                                      
                                      for(int i = 0; i < total; i++) {
                                          try {
                                              Thread.sleep(100);

                                              if(cancelled) {
                                                  cancelled = false;
                                                  return null;
                                              }

                                              listItems.add(fontNames.get(i));
                                              
                                              ta.setText(ta.getText() + fontNames.get(i) + "\n");
                                              ta.requestFocus();
                                              
                                              t.setText("" + listView.getItems().size() + " font names added");
                                              
                                              updateProgress(i + 1, total);
                                          } catch(java.lang.Exception e) {}
                                      }
                                      return null;
                                  }
                              };
                          }
                      };
                      
                      listView.setItems(listItems);
                      t.setText("" + listView.getItems().size() + " font names added");

                      pb.progressProperty().bind(s.progressProperty());
              
                      s.start();
                  }
              });
              final Button bCancel = new Button("Cancel");
              bCancel.setLayoutX(100);
              bCancel.setLayoutY(300);
              bCancel.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent event) {
                      cancelled = true;
                  }
              });

              root.getChildren().addAll(listView, ta, t, bGo, bCancel, pb);
              
              stage.setScene(scene);
              stage.show();
          }
          public static void main(String[] args) {
              Application.launch(LargeListViewIssue.class, args);
          }
      }

      Attachments

        Activity

          People

            leifs Leif Samuelsson (Inactive)
            lianqli Lianqi Li (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: