tailieunhanh - Java 6 Platform Revealed phần 5

Tham khảo tài liệu 'java 6 platform revealed 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ả | CHAPTER 4 AWT AND SWING UPDATES 71 One last tidbit worth mentioning is the getTrayiconSize method of SystemTray. If you don t use a prefabricated image as the icon on the system tray you can ask the system what size image to create. Then just create a buffered image draw on it and pass it along to the Trayicon constructor as shown here Dimension dim Bufferedimage bi new Bufferedimage Graphics g then draw on image before associating with tray icon Trayicon trayicon new trayicon bi text popup Dialog Modality- Top-level pop-up windows in Java-speak are called dialog boxes. They aren t the main windows frames of an application they re typically used to interact with a user either to display a message or accept user input. Pre-Mustang dialog boxes were by default modeless with an option to be modal. When a dialog box was modal other windows of the application were blocked from accepting input unless the window had the dialog box as its owner. Once the user reacted to the dialog accordingly by entering the input or just closing the dialog input to other windows of the application became accessible again. That is basically the limitations of modality with predecessors to Mustang. Along comes Java 6 and you have more options. No longer are you limited in scope to one level of modality on or off . Now you have four distinct settings defined by the new enumeration whose types are shown in Table 4-3. Table 4-3. Enumeration APPLiCATiON_MODAL DOCUMENT_MODAL MODELESS TOOLKiT_MODAL Before describing each of the modalities it is important to talk about them in the context of their default settings and the set of Dialog and JDialog constructors of which there are 14 and 16 respectively. The default modality is defined by the DEFAULT_MODALiTY_ TYPE constant of the Dialog class. Calling the setModal method with a value of false is the obvious