File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Swing Renders Native Controls? (getSystemLookAndFeelClassName) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing Renders Native Controls? (getSystemLookAndFeelClassName)" Watch "Swing Renders Native Controls? (getSystemLookAndFeelClassName)" New topic

Swing Renders Native Controls? (getSystemLookAndFeelClassName)

Bryan Cairns

Joined: Oct 27, 2007
Posts: 10
I have a read several books on java and studying for the SCJP exam.

Everything I have read says that Java draws the controls (for example a button). Where other languages / frameworks like .Net, QT framework, SWT, and wxWidgets create instances of the native controls from the OS.

That swing will create instances of native controls rather then draw them when you use:

Can anyone shed some light on this?

Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2452
The default Look and Feel (LAF) for Swing is the Metal LAF.

When you use: UIManager.getSystemLookAndFeelClassName() it doesn't not mean that native controls will be used. It means that Swing will use the default LAF for the platform the application is running on. The controls will be painted by Swing to look like the controls for that platform.
Bryan Cairns

Joined: Oct 27, 2007
Posts: 10
One thing I found on google:

Both WindowsLookAndFeel and GTKLookAndFeel are using native invocations to paint themselves. That's why they are using much more memory than "pure java" LookAndFeels, because abstraction level is doubled
I agree. Here's the link:
subject: Swing Renders Native Controls? (getSystemLookAndFeelClassName)
It's not a secret anymore!