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

Using Pagination with Group leads to IllegalArgumentException

XMLWordPrintable

    • x86_64
    • generic

      A DESCRIPTION OF THE PROBLEM :
      The issue shows up in a very simple test case containing an FXML file with a hierarchy of <ScrollPane><Group><Pagination> for which the pagination has an indeterminate number of pages. Although it is possible to select the final numbered page in the UI, a subsequent click on the ">" button causes an IllegalArgumentException to be thrown.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Build and run the test case.
      2. Click on the final page number in the UI.
      3. Click on the next button (">") in the UI.
      4. The console displays an exception.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The exception was not expected.
      ACTUAL -
      Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentExcepti
      on: Children: duplicate children added: parent = HBox@a1af07e[styleClass=control
      -box]
              at javafx.graphics/javafx.scene.Parent$3.onProposedChange(Parent.java:56
      5)
              at javafx.base/com.sun.javafx.collections.VetoableListDecorator.add(Veto
      ableListDecorator.java:206)
              at javafx.controls/javafx.scene.control.skin.PaginationSkin$NavigationCo
      ntrol.initializePageIndicators(PaginationSkin.java:915)
              at javafx.controls/javafx.scene.control.skin.PaginationSkin$NavigationCo
      ntrol.updatePageIndex(PaginationSkin.java:954)
              at javafx.controls/javafx.scene.control.skin.PaginationSkin$NavigationCo
      ntrol.lambda$initializeNavigationHandlers$4(PaginationSkin.java:899)
              at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleChange.fire
      ValueChangedEvent(ExpressionHelper.java:181)
              at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedE
      vent(ExpressionHelper.java:80)
              at javafx.base/javafx.beans.property.IntegerPropertyBase.fireValueChange
      dEvent(IntegerPropertyBase.java:107)
              at javafx.base/javafx.beans.property.IntegerPropertyBase.markInvalid(Int
      egerPropertyBase.java:114)
              at javafx.base/javafx.beans.property.IntegerPropertyBase.set(IntegerProp
      ertyBase.java:148)
              at javafx.controls/javafx.scene.control.Pagination.setCurrentPageIndex(P
      agination.java:273)
              at javafx.controls/javafx.scene.control.skin.PaginationSkin.selectNext(P
      aginationSkin.java:452)
              at javafx.controls/javafx.scene.control.skin.PaginationSkin.access$3100(
      PaginationSkin.java:80)
              at javafx.controls/javafx.scene.control.skin.PaginationSkin$NavigationCo
      ntrol.lambda$initializeNavigationHandlers$3(PaginationSkin.java:892)
              at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubbli
      ngEvent(CompositeEventHandler.java:86)
              at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubbling
      Event(EventHandlerManager.java:238)
              at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubbling
      Event(EventHandlerManager.java:191)
              at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBub
      blingEvent(CompositeEventDispatcher.java:59)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:58)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.ja
      va:74)
              at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:4
      9)
              at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
              at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8865)
              at javafx.controls/javafx.scene.control.Button.fire(Button.java:200)
              at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.
      mouseReleased(ButtonBehavior.java:206)
              at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle
      (InputMap.java:274)
              at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHan
      dlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
              at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubbli
      ngEvent(CompositeEventHandler.java:80)
              at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubbling
      Event(EventHandlerManager.java:238)
              at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubbling
      Event(EventHandlerManager.java:191)
              at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBub
      blingEvent(CompositeEventDispatcher.java:59)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:58)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(B
      asicEventDispatcher.java:56)
              at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent
      (EventDispatchChainImpl.java:114)
              at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.ja
      va:74)
              at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:5
      4)
              at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
              at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:38
      76)
              at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1300(Scene.jav
      a:3604)
              at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1874)

              at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene
      .java:2613)
              at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$Mouse
      EventNotification.run(GlassViewEventHandler.java:397)
              at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$Mouse
      EventNotification.run(GlassViewEventHandler.java:295)
              at java.base/java.security.AccessController.doPrivileged(Native Method)
              at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambd
      a$handleMouseEvent$2(GlassViewEventHandler.java:434)
              at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRe
      nderLock(QuantumToolkit.java:389)
              at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handl
      eMouseEvent(GlassViewEventHandler.java:433)
              at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)

              at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
              at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native M
      ethod)
              at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(
      WinApplication.java:175)
              at java.base/java.lang.Thread.run(Thread.java:844)


      ---------- BEGIN SOURCE ----------
      >>> sample/Main.java

      package sample;

      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.stage.Stage;

      public class Main extends Application {

          @Override
          public void start(Stage primaryStage) throws Exception{
              Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
              primaryStage.setTitle("Hello World");
              primaryStage.setScene(new Scene(root, 300, 275));
              primaryStage.show();
          }

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

      >>> sample/sample.fxml

      <?xml version="1.0" encoding="UTF-8"?>

      <?import java.lang.*?>
      <?import java.util.*?>
      <?import javafx.scene.*?>
      <?import javafx.scene.control.*?>
      <?import javafx.scene.layout.*?>

      <ScrollPane prefHeight="400" prefWidth="600" xmlns:fx="http://javafx.com/fxml/1">
          <Group>
              <Pagination prefHeight="200" prefWidth="200"/>
          </Group>
      </ScrollPane>


      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The exception can be avoided by replacing Group with the following class:

      >>> sample/SampleGroup.java

      package sample;

      import javafx.beans.DefaultProperty;
      import javafx.collections.ObservableList;
      import javafx.scene.Node;
      import javafx.scene.Parent;

      @DefaultProperty("children")
      public class SampleGroup extends Parent {
          @Override public ObservableList<Node> getChildren() {
              return super.getChildren();
          }
      }


      FREQUENCY : always


        1. Main.java
          0.6 kB
        2. sample.fxml
          0.4 kB
        3. SampleGroup.java
          0.3 kB

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: