Fixed painting switch on some java versions.