The first program helloworld in the j2se graphic interface (with pictures and truth)

Source: Internet
Author: User

Creating a project is the same as creating a Java program.

Import Java. AWT. graphics; import javax. swing. jframe; import javax. swing. jpanel; public class simpleswinghelloworld {/***** @ title: Main * @ description: program entry * @ Param ARGs setting file * @ return void return type * @ throws * @ author mrjing * @ date 11:57:36 */public static void main (string [] ARGs) {jframe myframe = new mysimpleswing (); myframe. setdefaclocloseoperation (jframe. exit_on_close); myframe. setv Isible (true) ;}/ ***** @ classname: mysimpleswing * @ description: interface Class * @ author mrjing * @ date 2012-8-2 11:58:20 PM **/class mysimpleswing extends jframe {public mysimpleswing () {settitle ("window title"); setsize (default_width, default_height ); add (New mypanel ();} public static final int default_width = 400; public static final int default_height = 300;} class mypanel extends jpanel {public void paintcompo NENT (Graphics g) {super. paintcomponent (g); G. drawstring ("Hello world! ", 100,150 );}}

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.