3.3. Displaying graphics and shapes using Java

3.3.1. Lines, rectangles, and ovals on Web pages

Before Java, using graphics on Web pages was considered to be a challenge for all Web programmers. Indeed, Java still remains one of the best technologies to provide graphics capabilities on the World Wide Web. At a basic level, Java provides a set of simple functions to draw fundamental graphic shapes including lines, rectangles, and ovals on your Web pages. Some frequently used graphics functions and their calling syntax are listed below:

drawLine(x1,y1,x2,y2)Draws a line from position (x1,y1) to (x2,y2) in the applet window.
drawRect(x1,y1,w,h)Draws a rectangle at position (x1,y1) with w (i.e., width) and h (i.e., height) pixels.
fillRect(x1,y1,w,h) ...

Get Practical Web Technologies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.