In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "what are the differences between SWING and AWT mini-applications", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what are the differences between SWING and AWT mini-applications" this article.
The difference between SWING and AWT applets, you may have used AWT for graphical user interface (GUI) design before, how does it feel? Now that JAVA2 provides the Swing package, it shows you richer features, and the interface designed with it will be more friendly, so let's take a look.
In the past, you designed applets to extend Applet (java.applet.Applet); now to use the Swing package, you need to extend JApplet (javax.swing.JApplet). Let's first look at an example of extending JApplet applets, and then analyze the difference between the two.
The source code of the program is as follows: (JAppletTest.java)
Import javax.swing.*; import java.awt.*; import java.event.*; public class JAppletTest extends JApplet {public void init () {Container contentPane = getContentPane (); Icon icon = new ImageIcon ("swing.gif", "A GIF on a swing"); JLabel label = new JLabel ("Swing!", icon, SwingConstants.CENTER); contentPane.add (label, BorderLayout.CENTER);}}
There are a few points to note:
1. The * line of the program is not necessary, because the JApplet class uses an instance of BorderLayout as the layout manager of its content pane, and the default constraint of BorderLayout is BorderLayout.CENTER, so the * line of the program is not necessary.
2. The default layout manager for Applet is FlowLayout, while the default constraint for FlowLayout is FlowLayout.LEFT, which is one of the most significant differences between the two.
3. JApplet is a container that contains only one component, which is an instance of JRootPane, while JRootPane contains a container called the content pane.
4. The content Pane, which contains everything related to a specific applet. That is, the applet must add all the components to the content pane instead of adding them directly to the applet. 5. We should not set up the layout manager directly for the applet.
6. An instance of JApplet can have a menu bar, which is specified by the setJMenuBar method, while an AWT applet cannot.
AWT is based on the local method of CumberCraft + program, its running speed is relatively fast; Swing is an AWT-based Java program, its running speed is relatively slow. That's the difference between SWING and AWT applets.
These are all the contents of this article entitled "what are the differences between SWING and AWT applets?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.