Java developers often need to use graphics and drawing APIs. Due to limited capability of Java SDK, Microsoft’s DirectX API (DirectDraw or ddraw) on Window machine results into drawing problems when using external graphics accelerator card and thus Swing component drawing starts flickering.
The work around to this problem is to set ddraw flag off. There are separate methods to disable this flag in Java Application and in Java Applet.
1) For Java Application:
Either add below line in main function as the first line:
System.getProperties().Put(“sun.java2d.noddraw”, “true”);
OR
Use the below option in command prompt to run a Jar file:
java -Dsun.noddraw=true -jar examle.jar
2) For Java Applet
In Applet to make ddraw flag off user has to set the Java Runtime Parameters in Java plug-in control panel by.
For Java Versions lesser than 6.0 :
Go to Control Panel > Java Plug-in > Advanced and enter “-Dsun.java2d.noddraw=true” (without quotes)
into the Java Runtime Parameters test box.
For Java plug-in versions higher than 6.0 :
Go to Control Panel > Java Plug-in > Java then click “view” and enter “-Dsun.java2d.noddraw=true” (without quotes) into the Java Runtime Parameters text box.