One problem with this aproach is that not all GUIs support changing the fonts, colors, and so on of their native peers. Another problem is that this approach adds an additional level of indirection that cuts into performance.
An alternate approach is to implement only very basic graphics primitives like
drawString()
and drawLine()
in native code, then draw the components like buttons and labels using those graphics primitives.
In Java 1.2 and later (not yet supported by any web browsers but useful for
stand-alone applications) the javax.swing
package provides a set of classes that do exactly this. The Swing classes provide parallels to
many standard AWT components with different names but similar or
expanded interfaces. For instance, a JLabel
is the Swing equivalent of a java.awt.Label
. A JButton
is the Swing equivalent of a java.awt.Button
. Swing also includes
some additional GUI widgets
that are not available in the standard AWT,
a tree control for example.