Steps to create a swing

Source: Internet
Author: User

(1) Import swing Package

(2) Select the interface style

(3) Setting the top-level container

(4) Setting buttons and labels

(5) Placing the component on the container

(6) Add a border to the component

(7) Handling events

(8) Auxiliary technical support

1  Packagecom.myswing;2 Importjava.awt.Dimension;3 ImportJava.awt.Toolkit;4 5 Importjavax.swing.*;6  Public classoneswing {7 8     Private Static voidCreateandshowgui () {9         Ten  One         //Creating and setting Windows AJFrame frame =NewJFrame ("Helloworldswing"); -Frame.setdefaultcloseoperation (Jframe.exit_on_close);//the action of the Close button is the exit window -      the         //Add Panel -JPanel Panel =NewJPanel (); - Frame.setcontentpane (panel); -          +         //Add "Hello World" tab -JLabel label =NewJLabel ("Hello World"); + panel.add (label); A  at         //Set Window Size -Frame.setsize (400, 100); -          -         //the action of the Close button is the exit window - frame.setdefaultcloseoperation (jframe.exit_on_close); -          in         //The Settings window is visible and is not visible by default -Frame.setvisible (true); to          +         //fixed window size -Frame.setresizable (false); the           *     } $ Panax Notoginseng      Public Static voidMain (string[] args) { - Createandshowgui (); the     } +}

Steps to create a swing

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.