Skip to content

Commit 597a9a4

Browse files
SWinxyTheShermanTanker
authored andcommitted
8301822: BasicLookAndFeel does not need to check for null after checking for type
Reviewed-by: serb
1 parent 3b05a94 commit 597a9a4

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,23 +2243,20 @@ public void eventDispatched(AWTEvent ev) {
22432243
}
22442244
}
22452245
}
2246-
/* Activate a JInternalFrame if necessary. */
2247-
if (eventID == MouseEvent.MOUSE_PRESSED) {
2248-
Object object = ev.getSource();
2249-
if (!(object instanceof Component)) {
2250-
return;
2251-
}
2252-
Component component = (Component)object;
2253-
if (component != null) {
2254-
Component parent = component;
2255-
while (parent != null && !(parent instanceof Window)) {
2256-
if (parent instanceof JInternalFrame) {
2246+
2247+
// Activate a JInternalFrame if necessary.
2248+
if (eventID == MouseEvent.MOUSE_PRESSED
2249+
&& ev.getSource() instanceof Component parent) {
2250+
while (parent != null && !(parent instanceof Window)) {
2251+
if (parent instanceof JInternalFrame internalFrame) {
2252+
try {
22572253
// Activate the frame.
2258-
try { ((JInternalFrame)parent).setSelected(true); }
2259-
catch (PropertyVetoException e1) { }
2254+
internalFrame.setSelected(true);
2255+
} catch (PropertyVetoException ignored) {
22602256
}
2261-
parent = parent.getParent();
22622257
}
2258+
2259+
parent = parent.getParent();
22632260
}
22642261
}
22652262
}

0 commit comments

Comments
 (0)