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

TextFieldSkin/Behavior: misbehavior on switching skin

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10
      Java 13.0.2 (Azul jdk)
      JavaFX 13.0.2
      JMetro 11.6.7
      Gradel: 6.2.1

      A DESCRIPTION OF THE PROBLEM :
      I seems like when switching between skins, the dispose method is not cleaning up listeners properly. I found this while working with JMetro (https://github.com/JFXtras/jfxtras-styles/tree/master/src/jmetro). I started my application using the default theme, and then when I tried to switch to JMetro, I got an error. I reported this to the developer of JMetro (https://github.com/JFXtras/jfxtras-styles/issues/144), who believes that it is actually a JavaFX issue.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Start the Application without using JMetro
      2. Switch to using JMetro

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      UI should change to JMetro theme, with no errors.
      ACTUAL -
      UI does look like it changes to JMetro, but the following error occurs:

      Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
      at javafx.controls/javafx.scene.control.skin.TextFieldSkin.updateSelection(TextFieldSkin.java:740)
      at javafx.controls/javafx.scene.control.skin.TextFieldSkin.lambda$new$3(TextFieldSkin.java:233)
      at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:136)
      at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
      at javafx.base/javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:106)
      at javafx.base/javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:113)
      at javafx.base/javafx.beans.property.ObjectPropertyBase$Listener.invalidated(ObjectPropertyBase.java:234)
      at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:136)
      at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
      at javafx.base/javafx.beans.binding.ObjectBinding.invalidate(ObjectBinding.java:170)
      at javafx.graphics/javafx.scene.text.Text.doGeomChanged(Text.java:847)
      at javafx.graphics/javafx.scene.text.Text$1.doGeomChanged(Text.java:159)
      at javafx.graphics/com.sun.javafx.scene.shape.TextHelper.geomChangedImpl(TextHelper.java:106)
      at javafx.graphics/com.sun.javafx.scene.NodeHelper.geomChanged(NodeHelper.java:137)
      at javafx.graphics/javafx.scene.text.Text$9.invalidated(Text.java:831)
      at javafx.base/javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
      at javafx.base/javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
      at javafx.graphics/javafx.css.StyleableObjectProperty.set(StyleableObjectProperty.java:82)
      at javafx.graphics/javafx.css.StyleableObjectProperty.applyStyle(StyleableObjectProperty.java:68)
      at javafx.graphics/javafx.scene.CssStyleHelper.transitionToState(CssStyleHelper.java:787)
      at javafx.graphics/javafx.scene.Node.doProcessCSS(Node.java:9660)
      at javafx.graphics/javafx.scene.Node$1.doProcessCSS(Node.java:472)
      at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSSImpl(NodeHelper.java:192)
      at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:145)
      at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1399)
      at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:125)
      at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98)
      at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:145)
      at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1399)
      at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:125)
      at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98)
      at javafx.controls/com.sun.javafx.scene.control.ControlHelper.superProcessCSSImpl(ControlHelper.java:63)
      at javafx.controls/com.sun.javafx.scene.control.ControlHelper.superProcessCSS(ControlHelper.java:55)
      at javafx.controls/javafx.scene.control.Control.doProcessCSS(Control.java:886)
      at javafx.controls/javafx.scene.control.Control$1.doProcessCSS(Control.java:89)
      at javafx.controls/com.sun.javafx.scene.control.ControlHelper.processCSSImpl(ControlHelper.java:67)
      at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:145)
      at javafx.graphics/javafx.scene.Parent.doProcessCSS(Parent.java:1399)
      at javafx.graphics/javafx.scene.Parent$1.doProcessCSS(Parent.java:125)
      at javafx.graphics/com.sun.javafx.scene.ParentHelper.processCSSImpl(ParentHelper.java:98)
      at javafx.graphics/com.sun.javafx.scene.NodeHelper.processCSS(NodeHelper.java:145)
      at javafx.graphics/javafx.scene.Node.processCSS(Node.java:9542)
      at javafx.graphics/javafx.scene.Scene.doCSSPass(Scene.java:569)
      at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2469)
      at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:412)
      at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
      at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:411)
      at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:438)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:563)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:543)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:536)
      at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:342)
      at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
      at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
      at java.base/java.lang.Thread.run(Thread.java:830)

      ---------- BEGIN SOURCE ----------
      package ca.ewert.jmetrotest;

      import javafx.application.Application;
      import javafx.geometry.Insets;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.layout.*;
      import javafx.stage.Stage;
      import jfxtras.styles.jmetro.*;

      public class JMetroTestApplication extends Application {

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

        private Scene scene;

        @Override
        public void start(Stage primaryStage) {
          String javaVersion = System.getProperty("java.version");
          String javafxVersion = System.getProperty("javafx.version");
          Label label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
          TextField textField = new TextField();
          CheckBox checkBox = new CheckBox("Hello JavaFx");
          Button button = new Button("Switch to JMetro");
          button.setOnAction(event -> {
            this.switchToJMetro();
          });

          VBox vBox = new VBox();
          vBox.setPadding(new Insets(10.0));
          vBox.setSpacing(5.0);
          vBox.getChildren().addAll(label, textField, checkBox, button);
          this.scene = new Scene(vBox, 800, 600);
          //this.switchToJMetro();
          primaryStage.setScene(scene);
          primaryStage.setTitle("JMetro Test");
          primaryStage.show();
        }

        private void switchToJMetro() {
          System.out.println("Switching to JMetro");
          JMetro jMetro = new JMetro(Style.LIGHT);
          jMetro.setScene(this.scene);
        }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fastegal Jeanette Winzenburg
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: