The test fails because a frame which should be drawn later sometimes goes under earlier-drawn one (running on EDT).
Please run the following test code:
import java.awt.*;
public class EDT {
public static void main(final String[] args) throws Exception {
EventQueue.invokeAndWait(() -> {
// delay to ensure that the red frame
// isn't drawn before the big one
try { Thread.currentThread().sleep(2000); }
catch (Exception e) { System.out.println("can't sleep"); }
Frame f = new Frame();
f.setSize(200, 200);
f.setLocation(0, 0);
f.setVisible(true);
System.out.println("1");
});
//Thread.currentThread().sleep(100);
EventQueue.invokeAndWait(() -> {
Frame f = new Frame();
f.setSize(120, 150);
f.setLocation(0, 0);
f.setBackground(Color.red);
f.setVisible(true);
System.out.println("2");
});
}
}
behavior:
Ubuntu 14.04 linux + GNOME + JDK9 b93 (as well as Win7): red frame is always on top (as expected)
Ubuntu 15.04 linux + GNOME + JDK9 b93 + HiDPI display:
the red frame (2nd) goes under the 1st. Output is "12" (as expected).
could it be some EDT violation? please note that "invokeAndWait" is called when drawing the 1st frame. the same unexpected behavior if wrap all the code with the single "invokeAndWait"
if enable the commented delay then the expected behavior is observed