1
votes

While java programs are platform independent, the JVM itself is platform dependent. I am interested in knowing how Java draws the application GUI (buttons and text) on the screen.

Under Windows, control objects such as buttons are usually created using a window(from user32.dll) or a rectangular region(from gdi32.dll), text is drawn later to the corresponding window/region handle using the provided user32/gdi32 text draw functions.

I tried running a simple two button Java gui application using swing and hooking the majority of create region/window and text draw functions from gdi32.dll and user32.dll, but so far, it seems the Java program is just using these native dlls for drawing the main window frame only.

Does Java.exe uses some other dlls to draw buttons and other controls on the screen ? And if so, why is this case when there are already available native dlls for drawing ?

2
I read both but still cannot find an answer, I am not interested on the high level implementation of the controls, I know that swing is not using the provided high level windows controls(buttons,menus..etc), I am interested on the basic geometric building blocks of these controls, for instance if we have a rectangular button on the screen, the pixels of the rectangle corresponding to the button boundary has to be drawn on the screen at some point. gdi32 and user32 are core windows components, and my thought is that they have to be used at some point for drawing the pixels on the screen.Ibrahim
java.exe doesn’t draw anything; it’s just a launcher for the JVM, which also doesn’t draw anything, but provides an infrastructure for executing Java code, which may use native libraries, so you have to address the particular code and libraries for your question. Since Swing uses pluggable look & feels, there isn’t a single answer for Swing—it depends on the Look&Feel…Holger

2 Answers

4
votes

On Windows Java2D uses Direct3D renderer to draw primitives by default. You may disable it by specifying -Dsun.java2d.d3d=false. In this case GDI renderer will be used.

Add -Dsun.java2d.trace=log,verbose option to trace which Java2D primitives are called in your Swing application.

0
votes

From the Wikipedia Article:

Unlike AWT components, Swing components are not implemented by platform-specific code. Instead, they are written entirely in Java and therefore are platform-independent. The term "lightweight" is used to describe such an element.