[JavaSE] GUI (graphical user interface), javasegui

Source: Internet
Author: User

[JavaSE] GUI (graphical user interface), javasegui

The objects provided by java for gui are in the java. Awt and javax. Swing packages.

Awt: The Abstract Window Toolkit relies on the platform to call the local method of the system.

Swing: a lightweight tool library fully implemented by java

 

Eclipse officially encapsulates a set of Swt control packages

 

Layout mode

Stream layout, border layout, grid layout, card layout, coordinate alignment, and panel layout

 

Frame

Get the Frame object, new and construct the parameter: String form title

Call the setSize () method of the Frame object to set the size, parameter: int width, int height

Call the setLocation () method of the Frame object to set the position. The parameter is the x coordinate of the int and the y coordinate of the int.

Call the setLayout () method of the Frame object to set the layout. Parameter: Flowayout object

 

Get the Button object, new and construct the parameter: String text display

Call the add () method of the Frame object to add a control. Parameter: Button Object

 

Call the setVisible () method of the Frame object. The parameter is true of Boolean.

 

A form is displayed, which is run by a sub-foreground thread. The main thread has ended.

Import java. awt. button; import java. awt. flowLayout; import java. awt. frame; public class GuiDemo {/*** @ param args */public static void main (String [] args) {Frame frame = new Frame ("I Am a form "); frame. setSize (400,300); frame. setLocation (500,200); frame. setLayout (new FlowLayout (); Button button = new Button ("Button"); frame. add (button); frame. setVisible (true );}}

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.