My Java Learning notes (20) about the framework overview

Source: Internet
Author: User
Tags terminates

1. In Java, a window with a top-level window that is not contained in another window is called a frame.

2. In the AWT library there is a class called frame that describes the top-level window, the swing version of this class named JFrame, which extends to the frame class.

3.JFrame is one of the very few swing components that are not drawn on the canvas. As a result, its decorated parts are drawn by the user's window system, not by swing.

Instance Code

Test class

Import Java.awt.*;import Javax.swing.jframe;public class Test {public static void main (string[] args) { Eventqueue.invokelater (New Runnable () {public void run () {simpleframe f = new Simpleframe (); F.setdefaultcloseoperation ( Jframe.exit_on_close); f.setvisible (True);}});}}

function Class

Import Javax.swing.jframe;public class Simpleframe extends jframe{private static final int default_width = 300;private STA Tic Final int default_height = 200;public Simpleframe () {setSize (default_width,default_height);}}

Output Results



The 4.Swing class is located in the Javax.swing package, and the package name Javax indicates that this is a Java extension package, not a core package.

5. All swing components must be configured by the event dispatch thread, which transfers the mouse click and key control to the user interface component.

6. Simple construction Framework is not automatically explicit, the frame period is not visible at the beginning. You can always draw the components of the framework at this stage before the explicit.

7. The above program does not exit after the main function main ends because the main thread terminates, and the time-allocation thread keeps the program active until the framework is closed or the System.exit method terminates the program.

My Java Learning notes (20) about the framework overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.