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