Abstract Window Toolkit: Difference between revisions

Content deleted Content added
Monkbot (talk | contribs)
m Task 18 (cosmetic): eval 8 templates: hyphenate params (20×);
Lehasa (talk | contribs)
Line 28:
 
== Mixing AWT and Swing components ==
 
Where there is a Swing version of an AWT component it will begin with J- and should be used exclusively, replacing the AWT version. For example in Swing, only use JButton, never Button class. As mentioned above, the AWT core classes, such as Color and Font, are still used as-is in Swing.
 
When drawing in Swing, use JPanel and override paintComponent(Graphics g) instead of the AWT paint() methods.
 
Prior to [[Java version history#Java SE 6 .28December 11.2C 2006.29|Java 6 Update 12]], mixing [[Swing (Java)|Swing]] components and basic AWT widgets often resulted in undesired side effects, with AWT widgets appearing on top of the Swing widgets regardless of their defined [[z-order]]. This problem was because the rendering architecture of the two widget toolkits was very different, despite Swing borrowing heavyweight top [[Container (data structure)#Graphic containers|containers]] from AWT.<ref>{{cite web
|url=http://java.sun.com/products/jfc/tsc/articles/mixing/index.html