Skip to content

Commit ca3e8ba

Browse files
hansonrhansonr
authored andcommitted
Allow component without parent into cycle (Desktop)
1 parent 93f29f2 commit ca3e8ba

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sources/net.sf.j2s.java.core/src/javax/swing/LayoutComparator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.ListIterator;
3333
import java.awt.Component;
3434
import java.awt.ComponentOrientation;
35+
import java.awt.Container;
3536
import java.awt.Window;
3637
import java.io.Serializable;
3738

@@ -120,7 +121,10 @@ public int compare(Object o1, Object o2) {
120121

121122
int ax = a.getX(), ay = a.getY(), bx = b.getX(), by = b.getY();
122123

123-
int zOrder = a.getParent().getComponentZOrder(a) - b.getParent().getComponentZOrder(b);
124+
Container ap = a.getParent();
125+
Container bp = b.getParent();
126+
// desktop will have no parent
127+
int zOrder = (ap == null ? 1 : bp == null ? -1 : ap.getComponentZOrder(a) - bp.getComponentZOrder(b));
124128
if (horizontal) {
125129
if (leftToRight) {
126130

0 commit comments

Comments
 (0)