Is it possible to use AWT layout managers with Swing components?

Scott Stanchfield

But of course!

Sometimes people have the impression that you can only use Swing or only use AWT. This is not the case.

Swing builds on top of AWT's Container class, and uses the same layout managers and much of the other component support that AWT does.

To use the AWT layout managers with a Swing GUI, simply include
import java.awt.*;

at the top of your source, as well as the Swing package imports that you need. You will then be able to access all of the AWT layout managers.

BTW: You can also use Swing's BoxLayout layout manager in AWT-only applications -- it's just a standard layout manager. Make sure you deliver the BoxLayout class, as well as the SizeRequirements class from Swing with your AWT application if you do this.

Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact