Content deleted Content added
foldoc attribution Template_talk:FOLDOC#It_doesn't_matter_whether_readers_care |
|||
(19 intermediate revisions by 15 users not shown) | |||
Line 1:
{{Short description|Java-based GUI toolkit}}
{{Use dmy dates|date=
[[File:Easy Java AWT example.jpg|thumb|250px|Windows form with some AWT examples]]
The '''Abstract Window Toolkit''' ('''AWT''') is [[Java (programming language)|Java]]'s original platform-dependent [[Windowing system|windowing]], [[graphic]]s, and [[user-interface]] [[widget toolkit]], preceding [[Swing (Java)|Swing]]. The AWT is part of the [[Java Foundation Classes]] (JFC) — the standard [[Application programming interface|API]] for providing a [[graphical user interface]] (GUI) for a Java program.<ref name="foldoc">{{foldoc|Abstract+Window+Toolkit}}</ref> AWT is also the GUI toolkit for a number of [[Java Platform, Micro Edition|Java ME]] profiles. For example, [[Connected Device Configuration]] profiles require Java [[software execution|runtime]]s on [[mobile telephone]]s to support the Abstract Window Toolkit.
== History ==
When [[Sun Microsystems]] first released Java in 1995, AWT widgets provided a thin level of abstraction over the underlying native user-interface. For example, creating an AWT [[check box]] would cause AWT directly to call the underlying native subroutine that created a check box. However,
In [[Java Platform, Standard Edition|J2SE 1.2]], the [[Swing (Java)|Swing]] toolkit largely superseded the AWT's widgets. In addition to providing a richer set of UI widgets, Swing draws its own widgets (by using [[Java 2D]] to call into low-level subroutines in the local graphics subsystem) instead of relying on the operating system's high-level user interface module. Swing provides the option of using either the native platform's [[Look and feel#Look and Feel in Widget Toolkits|"look and feel"]] or a cross-platform look and feel (the "Java Look and Feel") that looks the same on all windowing systems.
Line 18:
** Several [[layout manager]]s;
** The interface to [[input device]]s such as [[Mouse (computing)|mouse]] and [[Keyboard (computing)|keyboard]]; and
** A {{Javadoc:SE|package=java.awt.datatransfer|java/awt/datatransfer|module=java.desktop}} [[Java package|package]] for use with the [[Clipboard (software)|Clipboard]] and [[Drag and drop|Drag and Drop]].
* A basic set of GUI widgets such as buttons, text boxes, and menus. It also provides the [[Java AWT Native Interface|AWT Native Interface]], which enables [[Rendering (computer graphics)|rendering]] [[library (computer science)|libraries]] compiled to [[native code]] to draw directly to an AWT {{Javadoc:SE|java/awt|Canvas|module=java.desktop}} [[object (computer science)|object]] drawing surface.
AWT also makes some higher level functionality available to applications, such as:
Line 25:
* The ability to launch some desktop applications such as [[web browser]]s and [[Mail client|email clients]] from a Java application.
Neither AWT nor Swing
== 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 using the AWT paint() methods.
|url=http://java.sun.com/products/jfc/tsc/articles/mixing/index.html
|title=Mixing heavy and light components
Line 44:
|archive-date=23 December 2011
|url-status=live
}}</ref>
Starting in [[Java version history#Java SE 6
|url=http://download.java.net/jdk6/6u12/promoted/b02/changes/jdk6uN-b02.html
|title=Bug/RFE fixed in current JDK 6u12 build
Line 60 ⟶ 59:
== Example ==
<syntaxhighlight lang="java">
import java.awt.*;
import java.awt.event.
import java.awt.event.WindowEvent;
public class
public static void main(
frame.setLocationRelativeTo(null); // Centers the window
public void windowClosing(WindowEvent e) {▼
frame.dispose(); // Releases native screen resources
}
});▼
frame.setVisible(true);
}
▲ }
▲ public void windowClosing(WindowEvent e) {
▲ }
}
</syntaxhighlight>
Line 110 ⟶ 97:
|archive-date=19 March 2012
|url-status=live
}}</ref><ref>{{cite web
| url=http://rkennke.wordpress.com/2008/12/18/caciocavallo-architecture-overview/
Line 126 ⟶ 112:
|archive-date=13 March 2012
|url-status=live
}}</ref> All the necessary core-JDK modifications have since been pushed to [[OpenJDK|OpenJDK 7]],<ref>{{cite web
|url=http://mail.openjdk.java.net/pipermail/caciocavallo-dev/2009-September/000184.html
Line 132 ⟶ 117:
|date=20 September 2009
|publisher=openjdk.java.net
|quote=''You don't need anymore of those patches, with the latest FontManager push, everything is upstream now, so just use the Cacio repo, it's completely self contained.''
|access-date=7 March 2010
|archive-url=https://web.archive.org/web/20120319173102/http://mail.openjdk.java.net/pipermail/caciocavallo-dev/2009-September/000184.html
|archive-date=19 March 2012
|url-status=live
}}</ref> which means that Java can now be used on a graphics stack other than one of those provided by the official JDK ([[X Window System]], [[OpenGL]] or [[DirectX]]), by including an external library and setting some system properties. A [[DirectFB]] backend for Caciocavallo<ref name="rkennkeDirectFB">{{cite web
| url=http://rkennke.wordpress.com/2011/07/28/jdk7-and-cacio-coolness/
Line 152 ⟶ 136:
|archive-date=21 March 2012
|url-status=dead
}}</ref>
Line 161 ⟶ 144:
== References ==
{{
== External links ==
{{Wikibooks|Java Swings/AWT}}
{{Commons
* {{Javadoc:SE|package=java.awt|java/awt|module=java.desktop}} (AWT [[Javadoc]] API documentation)
* {{Javadoc:SE-guide|awt|AWT documentation}}
*[https://web.archive.org/web/20161215114326/http://www.java-forums.org/awt-swing/ AWT/Swing]
*[http://www.java-tips.org/java-se-tips-100019/21-java-awt.html java.awt] {{Webarchive|url=https://web.archive.org/web/20160829004424/http://www.java-tips.org/java-se-tips-100019/21-java-awt.html |date=29 August 2016 }}
{{Java desktop}}
{{Widget toolkits}}
[[Category:Articles with example Java code]]
[[Category:
[[Category:Widget toolkits]]
|