Applet Applicationa small program that can be executed in a Web browser to extend the functionality of a Web page in a browser.
Missing:1. Need to download applets and related files2, the function of the Applet is limitedExcellent:3. No installation required4, platform-independent5. Security
the life cycle of an AppletTo write an applet, you need to inherit the JApplet class, which provides the basic behavior of the applet program, and only needs to overwrite the method to complete our own applet program. Life cycle1. Initialization phase: Init methodat the beginning of the Applet execution, the Init method is automatically called. The Init method works by completing the initialization of the Applet. In general, the initialization and layout allocation of graphical components are done in this method. The Init method is only called once throughout the life cycle. 2. Execution phase: Start Methodafter initialization is complete, the Applet automatically calls the Start method and executes the code in it. Unlike the Init method, the Start method may be called multiple times throughout the life cycle. It is not only called after the Init method, but the Start method is also called when the Applet's current window is activated. 3. Abort phase: Stop MethodThe stop method is called when the applet is not needed, or when the applet is closed. In the Stop method, perform some cleanup or shutdown of some resource-intensive operations. The Stop method is only called once throughout the life cycle. 4. Releasing resources: Destroy Methodafter calling the Stop method, call the Destroy method to complete the final resource release, and so on. The Destroy method will only be executed once.
Heavyweight Graphics development tool--AWT library (java.awt package) The earliest graphical development tool in Java, but AWT is not very popular. Cons: 1, loss of flexibility. Most components contain native code codes. Unable to arbitrarily change the appearance of the component as needed, unable to add the group 2 arbitrarily on the component, want to personalize the control of the AWT, you need to write the C language native code, do not change the platform to rewrite and compile its own native code. Control Description: 1, container 2, Component label label, used to display text. button, click the button, will generate ActionEvent event, use ActionListener interface This event TextField text input box, in this component can enter the Text checkbox check box, provide the user multiple selection of components Choice Drop-down menu that provides the selected component as a menu ... 3. Layout Manager
BoderlayoutDivide the layout into five areas: East, West, south, north, middle. Components can be placed in these five areas, but each zone can be placed in only one component
FlowLayoutOrder the components horizontally, and if one row is unable to place all the components, the next line then joins the component in order from left to right GridLayout the components in rows and columns. Use GridLayout to set the layout to a few rows and columns, and then add the components in a horizontal order. CardLayout the container vertically, placing only one component at a time, putting the components into different layers and folding them up to see only the topmost components at a time. The gridbaglayout is the most flexible and allows you to set the exact location and size of the component placement. Event monitoring and Event handling: 1, Event 2, Event source 3, event listener capture and handle the event. Delegate Event mode (delegation model), event source different events delegated to different event listener classes for listening and processing. Another feature of this delegate model is that we only need to delegate the time of interest to the corresponding event listener class, and we don't have to do anything, including delegates, for events that don't need to be cared for.
make interface development easier--swingAWT does not meet our development needs for graphical interface design, so we have Swing. Swing was developed on the basis of AWT, which broke through the limitations of AWT and made up the fatal flaw of AWT, which was designed as a lightweight graphical development tool. Swing is a lightweight graphical development tool that does not have native code and is not dependent on the operating system.
container and Control description
Container: 1. Top container in Swing top container includes JFrame, JApplet, JDialog and JWindow. Said to be the top layer of the container, is actually understood should be the lowest level of the container, because it is closest to the operating system. In contrast to other Swing containers, the top container is characterized by the container not being a lightweight container, and some native code,swing require these top-level containers and operating systems to communicate. It is important to note that unlike AWT containers, components such as JButton can not be added directly to the top-level container, and other containers need to be added to the top container. 2, middle-tier container Swing middle-tier containers are lightweight, including JPanel, JScrollPane, JSplitPane and JToolBar and so on. These middle-tier containers have their own characteristics. For example, Jpnael supports double buffering functionality, facilitates processing of animations, jscrollpane windows that support scrolling, and jsplitpane divides layouts into two regions. 3, special containers Swing special containers include: JInternalFrame and JLayeredPane. JInternalFrame is used almost like JFrame, but it is a lightweight container that can be used to create a virtual interface; JLayeredPane is a layered container, in fact other containers are a layer in the JLayeredPane container.
Components of SwingThere are components in the AWT that are available in swing, but with a j in front of the name, such as the AWT Button in swing for JButton. Since the components in swing are lightweight components, the components in AWT are heavyweight, or that sentence, the components in swing are vastly improved in every way compared to AWT. In the implementation of interactive components, Swing components include JButton, ComboBox, JList, JMenu, JTextArea, and JTextField in the display aspect, implementing non-editable components including JLabel and JProgressBar components Implement editable display components including JColorChooser, Jfilechoose, JFileChooser, and JTable.
Swing's layout control
event monitoring and event handling mechanism for swingSimilar to AWT ...
In college, the mainstream Java graphics development plug-in is: Visual Editor and SWT Designer, and soon out of a jigloo, but went to the official website to see this thing has not been updated for a long time, but is said to be short, perfectly formed. SWT Designer was recently acquired by Google to re-integrate into its products, and then open source, now called:windowbuilder Pro, looks like the interface components are rich and powerful look, support swing, AWT, SWT, And Google's own GWT and so on.
The current mainstream Java GUI development tools are as follows:
1. Windowbuilder Pro
http://www.eclipse.org/windowbuilder/
Https://developers.google.com/java-dev-tools/download-wbpro?hl=zh-CN
2. Jigloo(the latest version is a 2010-year update, it seems that the project has not been done now)
http://www.cloudgarden.com/jigloo/
3. You can also directly use the IDE such as:NetBeans or myeclipse, both have their own graphics development drag and Drop tool
Related reading:
Eclipse for Visual GUI development 3 large GUI plugins
Http://www.cnblogs.com/NationWoo/archive/2011/05/31/2065176.html
Java GUI graphical interface development tool