Java software solutions foundations of program design 4th edition phần 5

Tiêu chuẩn thư viện lớp Java là một tập hợp hữu ích của các lớp học mà bất cứ ai cũng có thể sử dụng khi viết các chương trình Java. Thư viện lớp được tạo thành cụm các lớp học liên quan nhiều, đôi khi được gọi là Java API hoặc giao diện lập trình ứng dụng. | 366 CHAPTER 6 arrays listing continued Returns the primary panel containing the GUI. ------------------------------------------------------------------- public JPanel getPanel return primary Represents the listener for both check boxes. private class StyleListener implements ItemListener ---------------------------------------------------------------- Updates the style of the label font style. ---------------------------------------------------------------- public void itemStateChanged ItemEvent event int style if style if style new Font Helvetica style FONT_SIZE This program also uses the Font class which represents a particular character font. A Font object is defined by the font name the font style and the font size. The font name establishes the general visual characteristics of the characters. We are using the Helvetica font in this program. The style of a Java font can be plain bold italic or bold and italic combined. The check boxes in our graphical user interface are set up to change the characteristics of our font style. The style of a font is represented as an integer and integer constants defined in the Font class are used to represent the various aspects of the style. The con other button components 367 stant PLAIN is used to represent a plain style. The constants BOLD and ITALIC are used to represent bold and italic respectively. The sum of the BOLD and ITALIC constants indicates a style that is both bold and italic. The itemStateChanged method of the listener determines what the revised style should be now that one of the check boxes has changed state. It initially sets the style to be plain. Then each check box is consulted in turn using the isSelected method which returns a boolean value. First if the bold check box is selected checked then the style is set to bold. Then if the italic check box is selected the ITALIC constant is added to the style variable. .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
48    80    2    30-04-2024
7    60    2    30-04-2024
Đã 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.