Fix gray rectangle bug for Java apps