Skip to content

Commit 9a83dfe

Browse files
committed
8332431: NullPointerException in JTable of SwingSet2
Reviewed-by: abhiscxk, kizune
1 parent 01060ad commit 9a83dfe

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/java.desktop/share/classes/javax/swing/ToolTipManager.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -265,13 +265,19 @@ void showTipWindow() {
265265
toFind = new Point(screenLocation.x + preferredLocation.x,
266266
screenLocation.y + preferredLocation.y);
267267
} else {
268-
toFind = mouseEvent.getLocationOnScreen();
268+
if (mouseEvent != null) {
269+
toFind = mouseEvent.getLocationOnScreen();
270+
} else {
271+
toFind = screenLocation;
272+
}
269273
}
270274

271275
GraphicsConfiguration gc = getDrawingGC(toFind);
272276
if (gc == null) {
273-
toFind = mouseEvent.getLocationOnScreen();
274-
gc = getDrawingGC(toFind);
277+
if (mouseEvent != null) {
278+
toFind = mouseEvent.getLocationOnScreen();
279+
gc = getDrawingGC(toFind);
280+
}
275281
if (gc == null) {
276282
gc = insideComponent.getGraphicsConfiguration();
277283
}
@@ -301,8 +307,12 @@ void showTipWindow() {
301307
location.x -= size.width;
302308
}
303309
} else {
304-
location = new Point(screenLocation.x + mouseEvent.getX(),
305-
screenLocation.y + mouseEvent.getY() + 20);
310+
if (mouseEvent != null) {
311+
location = new Point(screenLocation.x + mouseEvent.getX(),
312+
screenLocation.y + mouseEvent.getY() + 20);
313+
} else {
314+
location = screenLocation;
315+
}
306316
if (!leftToRight) {
307317
if(location.x - size.width>=0) {
308318
location.x -= size.width;

0 commit comments

Comments
 (0)