-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
jfx21
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Same as selected in above combos
A DESCRIPTION OF THE PROBLEM :
Running the pasted sample code clearly shows this bug. It should be noted that I first detected this in Java 8 and then tested to see if fixed in Java 21 and still present. Under most conditions, the Custom Color dialog does appear but it appears that the issue relates to a TKStage peer window being null. Also, the exception trace is slightly different in Java 8 than Java 21 but both end in a NPE.
I had no alternative to select something in "Previously worked in the Release" but this also fails in Java/JavaFX 8.
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the pasted sample code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
To bring up the Custom Color dialog.
ACTUAL -
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "com.sun.javafx.tk.TKStage.setImportant(boolean)" because "<local2>" is null
at javafx.graphics@21.0.1/javafx.stage.Stage.doVisibleChanged(Stage.java:1182)
at javafx.graphics@21.0.1/javafx.stage.Stage$1.doVisibleChanged(Stage.java:190)
at javafx.graphics@21.0.1/com.sun.javafx.stage.StageHelper.visibleChangedImpl(StageHelper.java:63)
at javafx.graphics@21.0.1/com.sun.javafx.stage.WindowHelper.visibleChanged(WindowHelper.java:77)
at javafx.graphics@21.0.1/javafx.stage.Window$12.invalidated(Window.java:1212)
at javafx.base@21.0.1/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
at javafx.base@21.0.1/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
at javafx.graphics@21.0.1/javafx.stage.Window.setShowing(Window.java:1239)
at javafx.graphics@21.0.1/javafx.stage.Window.show(Window.java:1254)
at javafx.graphics@21.0.1/javafx.stage.Stage.show(Stage.java:277)
at javafx.controls@21.0.1/com.sun.javafx.scene.control.CustomColorDialog.show(CustomColorDialog.java:198)
---------- BEGIN SOURCE ----------
package utils;
import javafx.application.Application;
import javafx.event.*;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ColorPicker;
import javafx.geometry.Bounds;
import javafx.geometry.Insets;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.text.*;
import javafx.stage.Popup;
import javafx.stage.Stage;
/**
* Modified sample from:
* https://docs.oracle.com/javafx/2/ui_controls/color-picker.htm
*/
public class ColorPickerSample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
stage.setTitle("ColorPicker");
Scene scene = new Scene(new HBox(20), 400, 100);
HBox box = (HBox) scene.getRoot();
box.setPadding(new Insets(5, 5, 5, 5));
Button colourButton = new Button("Click Me");
colourButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
ColourSelectorPopup colourSelectorPopup = new ColourSelectorPopup();
colourSelectorPopup.show(colourButton);
}
});
Text text = new Text("Try the color picker!");
box.getChildren().addAll(colourButton, text);
stage.setScene(scene);
stage.show();
}
// colour selector pop-up
private class ColourSelectorPopup {
protected Popup popup;
private ColorPicker colorPicker;
public ColourSelectorPopup() {
buildUI();
}
private void buildUI() {
// colour picker
colorPicker = new ColorPicker(Color.AQUA);
colorPicker.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent evt) {
Color colourPickerColour = colorPicker.getValue();
System.out.println("selected colour: " + colourPickerColour);
hide();
}
});
// pop up
popup = new Popup();
popup.getContent().add(colorPicker);
popup.setAutoHide(true);
popup.setHideOnEscape(true);
}
public void show(Node ownerNode) {
//buildUI(); // build now that request to show has been made
double screenX = screenCoordinates(ownerNode).getMinX();
double screenY = screenCoordinates(ownerNode).getMinY();
popup.show(ownerNode, screenX + 64, screenY);
}
public void hide() {
popup.hide();
}
private Bounds screenCoordinates(Node node) {
Bounds bounds = node.getBoundsInLocal();
Bounds screenBounds = node.localToScreen(bounds);
return screenBounds;
}
} // class ColourSelectorPopup
} // class ColorPickerSample
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None that I've found
FREQUENCY : always
Same as selected in above combos
A DESCRIPTION OF THE PROBLEM :
Running the pasted sample code clearly shows this bug. It should be noted that I first detected this in Java 8 and then tested to see if fixed in Java 21 and still present. Under most conditions, the Custom Color dialog does appear but it appears that the issue relates to a TKStage peer window being null. Also, the exception trace is slightly different in Java 8 than Java 21 but both end in a NPE.
I had no alternative to select something in "Previously worked in the Release" but this also fails in Java/JavaFX 8.
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the pasted sample code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
To bring up the Custom Color dialog.
ACTUAL -
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException: Cannot invoke "com.sun.javafx.tk.TKStage.setImportant(boolean)" because "<local2>" is null
at javafx.graphics@21.0.1/javafx.stage.Stage.doVisibleChanged(Stage.java:1182)
at javafx.graphics@21.0.1/javafx.stage.Stage$1.doVisibleChanged(Stage.java:190)
at javafx.graphics@21.0.1/com.sun.javafx.stage.StageHelper.visibleChangedImpl(StageHelper.java:63)
at javafx.graphics@21.0.1/com.sun.javafx.stage.WindowHelper.visibleChanged(WindowHelper.java:77)
at javafx.graphics@21.0.1/javafx.stage.Window$12.invalidated(Window.java:1212)
at javafx.base@21.0.1/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
at javafx.base@21.0.1/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
at javafx.graphics@21.0.1/javafx.stage.Window.setShowing(Window.java:1239)
at javafx.graphics@21.0.1/javafx.stage.Window.show(Window.java:1254)
at javafx.graphics@21.0.1/javafx.stage.Stage.show(Stage.java:277)
at javafx.controls@21.0.1/com.sun.javafx.scene.control.CustomColorDialog.show(CustomColorDialog.java:198)
---------- BEGIN SOURCE ----------
package utils;
import javafx.application.Application;
import javafx.event.*;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ColorPicker;
import javafx.geometry.Bounds;
import javafx.geometry.Insets;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.text.*;
import javafx.stage.Popup;
import javafx.stage.Stage;
/**
* Modified sample from:
* https://docs.oracle.com/javafx/2/ui_controls/color-picker.htm
*/
public class ColorPickerSample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
stage.setTitle("ColorPicker");
Scene scene = new Scene(new HBox(20), 400, 100);
HBox box = (HBox) scene.getRoot();
box.setPadding(new Insets(5, 5, 5, 5));
Button colourButton = new Button("Click Me");
colourButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
ColourSelectorPopup colourSelectorPopup = new ColourSelectorPopup();
colourSelectorPopup.show(colourButton);
}
});
Text text = new Text("Try the color picker!");
box.getChildren().addAll(colourButton, text);
stage.setScene(scene);
stage.show();
}
// colour selector pop-up
private class ColourSelectorPopup {
protected Popup popup;
private ColorPicker colorPicker;
public ColourSelectorPopup() {
buildUI();
}
private void buildUI() {
// colour picker
colorPicker = new ColorPicker(Color.AQUA);
colorPicker.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent evt) {
Color colourPickerColour = colorPicker.getValue();
System.out.println("selected colour: " + colourPickerColour);
hide();
}
});
// pop up
popup = new Popup();
popup.getContent().add(colorPicker);
popup.setAutoHide(true);
popup.setHideOnEscape(true);
}
public void show(Node ownerNode) {
//buildUI(); // build now that request to show has been made
double screenX = screenCoordinates(ownerNode).getMinX();
double screenY = screenCoordinates(ownerNode).getMinY();
popup.show(ownerNode, screenX + 64, screenY);
}
public void hide() {
popup.hide();
}
private Bounds screenCoordinates(Node node) {
Bounds bounds = node.getBoundsInLocal();
Bounds screenBounds = node.localToScreen(bounds);
return screenBounds;
}
} // class ColourSelectorPopup
} // class ColorPickerSample
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None that I've found
FREQUENCY : always