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

[ToolBar] NPE when select from shrinked

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Cannot Reproduce
    • Affects Version/s: 7u6
    • Fix Version/s: 7u6
    • Component/s: javafx
    • Environment:

      2.2.0b13

      Description

      Run code:


      import javafx.application.Application;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.geometry.Orientation;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ToggleButton;
      import javafx.scene.control.ToolBar;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class NewClass extends Application {

          public static void main(String[] args) {
              launch(args);
          }
          ToolBar bar = new ToolBar();
          ToggleButton shrinkButon;

          @Override
          public void start(Stage stage) throws Exception {
              VBox vb = new VBox();

              bar = new ToolBar();
              bar.setOrientation(Orientation.VERTICAL);

              shrinkButon = new ToggleButton();
              shrinkButon.selectedProperty().addListener(new ChangeListener() {

                  @Override
                  public void changed(ObservableValue ov, Object t, Object t1) {
                      setSizes();
                  }
              });

              vb.getChildren().addAll(bar, shrinkButon);

              reset();

              Scene scene = new Scene(vb, 300, 500);
              stage.setScene(scene);
              stage.show();
          }

          protected void reset() {
              shrinkButon.setSelected(false);
              bar.getItems().clear();
              for (int i = 0; i < 10; i++) {
                  Button btn;
                  setSizes();
                  bar.getItems().add(btn = new Button("Button " + i) {

                      @Override
                      public void fire() {
                          System.out.println(getId());
                      }
                  });
                  btn.setId(String.valueOf(i));
              }
          }

          protected void setSizes() {
              if (shrinkButon.isSelected()) {
                  bar.setPrefSize(150, 80);
                  bar.setMaxSize(150, 80);
                  bar.setMinSize(150, 80);
              } else {
                  bar.setPrefSize(150, 400);
                  bar.setMaxSize(150, 400);
                  bar.setMinSize(150, 400);
              }
          }
      }

      Click toggle button to make ToolBar shrinked.
      Select any button from dropdown (">>" -> and click any).
      Click (">>") again

      I catch:

      java.lang.NullPointerException
      at com.sun.javafx.scene.control.skin.ButtonSkin.handleControlPropertyChanged(ButtonSkin.java:91)
      at com.sun.javafx.scene.control.skin.SkinBase$3.changed(SkinBase.java:282)
      at javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:107)
      at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:196)
      at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
      at javafx.beans.property.ReadOnlyObjectWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyObjectWrapper.java:195)
      at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:161)
      at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:130)
      at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:163)
      at javafx.scene.Node.setParent(Node.java:589)
      at javafx.scene.Parent$1.onProposedChange(Parent.java:371)
      at com.sun.javafx.collections.VetoableObservableList.remove(VetoableObservableList.java:172)
      at com.sun.javafx.collections.ObservableListWrapper.remove(ObservableListWrapper.java:263)
      at com.sun.javafx.collections.VetoableObservableList.remove(VetoableObservableList.java:179)
      at javafx.scene.Parent$1.onChanged(Parent.java:398)
      at com.sun.javafx.collections.VetoableObservableList.callObservers(VetoableObservableList.java:83)
      at com.sun.javafx.collections.ObservableListWrapper.add(ObservableListWrapper.java:154)
      at com.sun.javafx.collections.VetoableObservableList.add(VetoableObservableList.java:167)
      at com.sun.javafx.collections.ObservableListWrapper.add(ObservableListWrapper.java:144)
      at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.createNodeMenuItemChildren(ContextMenuContent.java:1194)
      at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.createChildren(ContextMenuContent.java:1031)
      at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.<init>(ContextMenuContent.java:1010)
      at com.sun.javafx.scene.control.skin.ContextMenuContent.updateVisualItems(ContextMenuContent.java:207)
      at com.sun.javafx.scene.control.skin.ContextMenuContent.access$1700(ContextMenuContent.java:83)
      at com.sun.javafx.scene.control.skin.ContextMenuContent$6.onChanged(ContextMenuContent.java:717)
      at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:134)
      at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:48)
      at com.sun.javafx.collections.ObservableListWrapper.callObservers(ObservableListWrapper.java:97)
      at com.sun.javafx.collections.TrackableObservableList.callObservers(TrackableObservableList.java:51)
      at com.sun.javafx.collections.ObservableListWrapper.addAll(ObservableListWrapper.java:171)
      at com.sun.javafx.collections.ObservableListWrapper.addAll(ObservableListWrapper.java:160)
      at com.sun.javafx.scene.control.skin.ToolBarSkin$ToolBarOverflowMenu$1.handle(ToolBarSkin.java:499)
      at com.sun.javafx.scene.control.skin.ToolBarSkin$ToolBarOverflowMenu$1.handle(ToolBarSkin.java:493)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
      at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
      at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
      at javafx.event.Event.fireEvent(Event.java:171)
      at javafx.scene.Scene$MouseHandler.process(Scene.java:3319)
      at javafx.scene.Scene$MouseHandler.process(Scene.java:3159)
      at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3114)
      at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1536)
      at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2256)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:227)
      at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
      at com.sun.glass.ui.View.notifyMouse(View.java:921)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
      at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:62)
      at java.lang.Thread.run(Thread.java:662)

        Attachments

          Activity

            People

            • Assignee:
              kwwong Kinsley Wong
              Reporter:
              akirov Alexander Kirov (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: