TAILIEUCHUNG - giáo trình Java By Example phần 5

Tham khảo tài liệu 'giáo trình java by example phần 5', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Table Commonly Used FontMetrics Methods. Method Description charWidth Returns the width of a character. getAscent Returns the font s ascent. getDescent Returns the font s descent. getFont Returns the associated Font object. getHeight Returns the font s height. getLeading Returns the font s leading line spacing . stringWidth Returns the width of a string. toString Returns a string of information about the font. NOTE If you haven t used fonts before some of the terms-leading ascent and descent-used in Table may be unfamiliar to you. Leading pronounced ledding is the amount of white space between lines of text. Ascent is the height of a character from the baseline to the top of the character. Descent is the size of the area that accommodates the descending portions of letters such as the tail on a lowercase g. Height is the sum of ascent descent and leading. See Figure for examples of each. Figure Ascent descent and leading determine the overall height of a font. Example Displaying Font Metrics Most of the methods listed in Table are self-explanatory. However you probably want a chance to see them in action. Listing is the source code for the MetricsApplet and Listing is the applet s HTML document. When you run the MetricsApplet applet you see the window shown in Figure . At the top of the window is a text box into which you can enter different strings of text. When you press Enter the applet displays the length of the string in pixels. Immediately below the text box is information about the current font. Figure This is Appletviewer running the MetricsApplet applet. Listing An Applet That Displays Text Metrics. import . import . http public class MetricsApplet extends Applet TextField textField public void init textField new TextField 20 add textField Default string public void paint Graphics g Font font getFont FontMetrics fontMetrics .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.