Tips on drawing a window using the jQuery drawing plug-in jCanvas

Source: Internet
Author: User
Jquery is another excellent Javascr into pt framework after prototype. It is a lightweight js library, in addition to compatible with CSS3, but also compatible with various browsers + ). JQuery allows you to easily process HTMLdocuments, events, and animation effects, and provides AJAX interaction... SyntaxHig for websites.

Jquery is another excellent Javascr into pt framework after prototype. It is a lightweight js library, in addition to compatible with CSS3, but also compatible with various browsers + ). JQuery allows you to easily process HTML documents, events, and animation effects, and provides AJAX interaction for websites.
HTML elements defined in HTML5 can be used to draw images and make animations on HTML pages through JavaScriptb. The recommended jCanvas is a jQuery drawing plug-in that encapsulates some graphics rendering methods and can generate images with just a few lines of code.

The following is the program code that JCanvas draws a window and listens.

Import java. awt .*;

Import javax. swing .*;

Import java. awt. event .*;

Class JCanvas extends JComponent

{

Public JCanvas ()

{

SetDoubleBuffered (true );

}

Public void paintComponent (Graphics g)

{

Dimension size = getSize ();

G. setColor (getBackground ());

G. fillRect (0, 0, size. width, size. height );

}

}

Class TestJCanvas

{

Public static void main (String s [])

{

MyWindowListener l = new MyWindowListener ();

JCanvas c = new JCanvas ();

C. setBackground (Color. yellow );

JFrame f = new JFrame ("Test JCanvas ...");

F. addWindowListener (l );

F. getContentPane (). add (c, BorderLayout. CENTER );

F. pack ();

F. setSize (500,400 );

F. show ();

}

}

Class MyWindowListener extends WindowAdapter

{Www.2cto.com

Public void windowClosing (WindowEvent e)

{

System. exit (0 );

}

}


Author: tbwshc
Related Article

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.