Java know how much (95) Drawing basics

Source: Internet
Author: User

To display text and drawings on a plane, you first determine a planar coordinate system. The Java language Convention, where a rectangular area on the display is the program drawing area, the coordinate origin (0,0) is located in the upper-left corner of the entire area. A coordinate point (x, y) corresponds to a pixel in the screen window, which is an integer. As shown in 12.1. The window size is specified by the width and height of the hypertext file. For example, the following hypertext determines that the window is 250 pixels wide and 400 pixels high:
<applet code = H.class width=250 height=400></applet>
Note: The applet is a Java applet that embeds Web pages and is no longer explained in this tutorial because it is rarely used at this time, and is only a sample reference.


Figure 12.1


Basic functions of the Raphics class
In the java.awt package, class graphics provides the ability to create fonts, set display colors, display images and text, and draw and fill various geometries. You can get a graphics object from a graphical object or by using the Getgraphics () method of component. The Graphics2D class inherits the graphics class and adds many state properties, allowing the application to draw more colorful graphics.

To draw in a component, you should generally override the paint () method for the subclass to which the component belongs, drawing in the overridden method. However, you want to draw in the JComponent subclass. For example, an inheritance defines a text area subclass that, in order to draw in such a text area sub-object, should rewrite Paintcomponent () to the text area subclass. The system automatically provides graphical objects to the program and passes the parameter G to the paint () method and the Paintcomponent () method.

Series Articles:

Java know how much (top)Java know how much (medium)Java knows how many () Java vectors (vector) and their applicationsJava know how much (79) hash table and its applicationJava know how much (80) graphical Interface design basicsJava know how much (81) frame window BasicsJava know how much (82) Introduction to tags, buttons, and button eventsJava know how much (83) Panel Basics: JPanel and JScrollPaneJava know how much (84) layout design of graphical interfaceJava know how much (85) text box and text areaJava know how much (86) input and output of text box and text areaJava know how much (87) Select boxes and radio buttonsJava know how many (88) lists and combo boxesJava know how many (89) lists and combo boxesJava know how much (90) menuJava know how much (91) dialog boxJava know how much (92) scroll barJava know how much (93) mouse EventsJava know how much (94) keyboard Events

Java know how much (95) Drawing basics

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.