Content deleted Content added
m date format audit, minor formatting, typo(s) fixed: For example → For example, |
foldoc attribution Template_talk:FOLDOC#It_doesn't_matter_whether_readers_care |
||
(18 intermediate revisions by 14 users not shown) | |||
Line 1:
{{Short description|Java-based GUI toolkit}}
{{Use dmy dates|date=June 2021}}
[[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 ==
Line 33:
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 46:
}}</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 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 129 ⟶ 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
Line 156 ⟶ 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]]
|