Lecture An introduction to computer science using java (2nd Edition): Chapter 13 - S.N. Kamin, D. Mickunas, E. Reingold

Chapter 13 - Java AWT – Part II (Optional). In this chapter we will: discuss the use of Java in animating World Wide Web applications, show how to write Java applets, introduce Java graphical components (. Textfields, Buttons, and Labels), show how Java programs can be made to react to user actions on Java graphical components, show how Java applications can be run from inside web browsers. | Chapter 13 Java AWT – Part II (Optional) Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by . Kamin, D. Mickunas, E. Reingold Chapter Preview In this chapter we will: discuss the use of Java in animating World Wide Web applications show how to write Java applets introduce Java graphical components (. Textfields, Buttons, and Labels) show how Java programs can be made to react to user actions on Java graphical components show how Java applications can be run from inside web browsers Frames A frame is a window with a title bar and a border The Frame class is a subclass of Container class Container class objects may have other components (. Buttons) added to them using the add method A typical Java GUI will create and display one or more frames To make a frame visible the message setVisbible(true) must be sent to the frame Layout Managers Governs how components are arranged inside a Container object The Container method setLayout allows the programmer to specify which layout manager (. FlowLayout) is desired for a particular container object The size of a Container object should be set explicitly by the programmer as well Can use pack() to set size to accommodate preferred sizes of components) Frame Example public class TwoButtons { Frame f; Button redButton, blueButton; public TwoButttons() { f = new Frame(“Two Buttons Frame”); redButton = new Button(“Red”); blueButton = new Button(“Blue”); (new Flowlayout()); (redButton); (blueButton); (); (true); } } UML Notation The filled diamond represents composition This shows that the class TwoButtons contains a class Frame which contains a class Buttons A good UML diagram only shows the classes and associations that are important to understanding the architecture This UML diagram does not include super classes like Component or Container Using Inheritance It is possible to use inheritance to allow TwoButtons to become a frame in its . | Chapter 13 Java AWT – Part II (Optional) Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by . Kamin, D. Mickunas, E. Reingold Chapter Preview In this chapter we will: discuss the use of Java in animating World Wide Web applications show how to write Java applets introduce Java graphical components (. Textfields, Buttons, and Labels) show how Java programs can be made to react to user actions on Java graphical components show how Java applications can be run from inside web browsers Frames A frame is a window with a title bar and a border The Frame class is a subclass of Container class Container class objects may have other components (. Buttons) added to them using the add method A typical Java GUI will create and display one or more frames To make a frame visible the message setVisbible(true) must be sent to the frame Layout Managers Governs how components are arranged inside a Container object The Container method setLayout allows .

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
Đã 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.