Details
-
Bug
-
Resolution: Fixed
-
P3
-
8u20
-
os-x, latest udev-sources
Description
Running the following app and resizing the window a few times yields an NPE
package controls;
import com.sun.javafx.scene.control.skin.TabPaneSkin;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Skin;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class PlaneSampleTabPane extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
HBox h = new HBox();
Scene s = new Scene(h,400,400);
{
TabPane tb = new TabPane();
{
Tab tab = new Tab("Tab 1");
Rectangle r = new Rectangle(100, 100);
r.setFill(Color.GREEN);
tab.setContent(new BorderPane(r));
tb.getTabs().add(tab);
}
{
Tab tab = new Tab("Tab 2");
Rectangle r = new Rectangle(100, 100);
r.setFill(Color.GREEN);
tab.setContent(new BorderPane(r));
tb.getTabs().add(tab);
}
HBox.setHgrow(tb, Priority.ALWAYS);
h.getChildren().add(tb);
}
{
TabPane tb = new TabPane();
{
Tab tab = new Tab("Tab 1");
tb.getTabs().add(tab);
}
{
Tab tab = new Tab("Tab 2");
tb.getTabs().add(tab);
}
HBox.setHgrow(tb, Priority.ALWAYS);
h.getChildren().add(tb);
}
primaryStage.setScene(s);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Stack:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabControlButtons.hideControlButtons(TabPaneSkin.java:1965)
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabControlButtons.showTabsMenu(TabPaneSkin.java:1918)
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabControlButtons.access$0(TabPaneSkin.java:1908)
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabHeaderArea.layoutChildren(TabPaneSkin.java:1243)
at javafx.scene.Parent.layout(Parent.java:1074)
at javafx.scene.Parent.layout(Parent.java:1080)
at javafx.scene.Parent.layout(Parent.java:1080)
at javafx.scene.Scene.doLayoutPass(Scene.java:530)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2358)
at com.sun.javafx.tk.Toolkit.lambda$2(Toolkit.java:314)
at com.sun.javafx.tk.Toolkit$$Lambda$117/1069868871.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:313)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:340)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:446)
at com.sun.javafx.tk.quantum.PaintCollector.liveRepaintRenderJob(PaintCollector.java:320)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$ViewEventNotification.run(GlassViewEventHandler.java:761)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$ViewEventNotification.run(GlassViewEventHandler.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleViewEvent(GlassViewEventHandler.java:794)
at com.sun.glass.ui.View.handleViewEvent(View.java:537)
at com.sun.glass.ui.View.notifyResize(View.java:863)
My proposed solution would be:
setVisible(false);
if( popup != null ) {
popup.getItems().clear();
popup = null;
}
package controls;
import com.sun.javafx.scene.control.skin.TabPaneSkin;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Skin;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class PlaneSampleTabPane extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
HBox h = new HBox();
Scene s = new Scene(h,400,400);
{
TabPane tb = new TabPane();
{
Tab tab = new Tab("Tab 1");
Rectangle r = new Rectangle(100, 100);
r.setFill(Color.GREEN);
tab.setContent(new BorderPane(r));
tb.getTabs().add(tab);
}
{
Tab tab = new Tab("Tab 2");
Rectangle r = new Rectangle(100, 100);
r.setFill(Color.GREEN);
tab.setContent(new BorderPane(r));
tb.getTabs().add(tab);
}
HBox.setHgrow(tb, Priority.ALWAYS);
h.getChildren().add(tb);
}
{
TabPane tb = new TabPane();
{
Tab tab = new Tab("Tab 1");
tb.getTabs().add(tab);
}
{
Tab tab = new Tab("Tab 2");
tb.getTabs().add(tab);
}
HBox.setHgrow(tb, Priority.ALWAYS);
h.getChildren().add(tb);
}
primaryStage.setScene(s);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Stack:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabControlButtons.hideControlButtons(TabPaneSkin.java:1965)
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabControlButtons.showTabsMenu(TabPaneSkin.java:1918)
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabControlButtons.access$0(TabPaneSkin.java:1908)
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabHeaderArea.layoutChildren(TabPaneSkin.java:1243)
at javafx.scene.Parent.layout(Parent.java:1074)
at javafx.scene.Parent.layout(Parent.java:1080)
at javafx.scene.Parent.layout(Parent.java:1080)
at javafx.scene.Scene.doLayoutPass(Scene.java:530)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2358)
at com.sun.javafx.tk.Toolkit.lambda$2(Toolkit.java:314)
at com.sun.javafx.tk.Toolkit$$Lambda$117/1069868871.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:313)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:340)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:446)
at com.sun.javafx.tk.quantum.PaintCollector.liveRepaintRenderJob(PaintCollector.java:320)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$ViewEventNotification.run(GlassViewEventHandler.java:761)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$ViewEventNotification.run(GlassViewEventHandler.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleViewEvent(GlassViewEventHandler.java:794)
at com.sun.glass.ui.View.handleViewEvent(View.java:537)
at com.sun.glass.ui.View.notifyResize(View.java:863)
My proposed solution would be:
setVisible(false);
if( popup != null ) {
popup.getItems().clear();
popup = null;
}