Study Note 20: GUI (i)

Source: Internet
Author: User

If you cherish your feathers too much, and don't make it a bit of damage, then you will lose two wings and never be able to fly again. --Shelley


The content of this lecture: graphical user interface (graphical users Interface, referred to as GUI)



From the picture above we can see that swing is an upgrade of AWT (different image sizes in Windows and Linux) that Java.swing.JFrame inherits Java.awt.Frame


JFrame is a subclass of a frame, belonging to a container class component, a top-level container (that is, a form), and a class that can be placed on other swing components.

Let's look at a GUI instance

<span style= "FONT-SIZE:18PX;" >import java.awt.*;import javax.swing.*;//x Extension meaning public class Text {public static void main (string[] args) {JFrame F=ne W JFrame ("My first GUI");//Create a frame instance and set the title//f.settitle ("My GUI"), set the window caption f.setlocation (300, 300);//Set the window display position, Unit is pixel f.setsize (400,300);//Set window size in pixels f.setresizable (false),//Set window size cannot change, default is truef.setvisible (true);//Display window, The default is Falsef.setdefaultcloseoperation (jframe.exit_on_close);//set to ensure that the JVM exits when the window is closed (very important)}}</span>
Object-oriented notation

<span style= "FONT-SIZE:18PX;" >import Java.awt.*;import javax.swing.*;//x The meaning of the extension public class Text extends jframe{//put the required swing components, defined here public static void Main (string[] args) {text t=new text ();} Public Text () {this.settitle ("My first GUI"); This.setlocation (+); this.setsize (400,300); This.setresizable ( FALSE); This.setvisible (true); This.setdefaultcloseoperation (Jframe.exit_on_close);}} </span>



This is where we go, take your time and enjoy it

Study Note 20: GUI (i)

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.