Đang chuẩn bị liên kết để tải về tài liệu:
Java Programming for absolute beginner- P15

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Java Programming for absolute beginner- P15:Hello and welcome to Java Programming for the Absolute Beginner. You probably already have a good understanding of how to use your computer. These days it’s hard to find someone who doesn’t, given the importance of computers in today’s world. Learning to control your computer intimately is what will separate you from the pack! By reading this book, you learn how to accomplish just that through the magic of programming. | JavaProgAbsBeg-07.qxd 2 25 03 8 53 AM Page 238 k 0 c c 0 2 V 0 a c E E s k a o k a s s First off it extends Frame so it is a Frame. It sets its background color to System-Color.control which as you might remember from the previous chapter is the color that your operating system uses for painting windows. Then it adds a WindowAdapter object as its WindowListener. Pay close attention to the syntax here. This is actually an inner-class declaration which you ll learn about later on in this chapter. Another cool thing it does is center itself no matter what size it is when it becomes visible. I did this by overriding the setVisible boolean method. If the argument passed in is true I get the screen size by calling Toolkit.getDefault-Toolkit .getScreenSize which returns a Dimension object representing the resolution of the computer screen whether it is 640 by 480 800 by 600 or whatever. The Toolkit class is the abstract subclass of all implementations of the AWT the default of which is different depending on what operating system you are running. To center the GUIFrame on screen I needed to know the screen size and the size of the GUIFrame. The position of the GUIFrame is set with the setLoca-tion int int method where the first int is the x location and the second int is the y location. The center location is half the difference of the screen width minus the GUIFrame width as the x position and half the difference of the screen height minus the GUIFrame height as the y position. super.setVisible visible is called so that the corresponding method in the Frame class can take care of actually making the GUIFrame visible. Take a look at Figure 7.7 to see what the GUIFrame looks like. Here is a test of the GUIFrame class GUIFrameTest GUIFrameTest Demonstrates the GUIFrame Class public class GUIFrameTest public static void main String args GUIFrame frame new GUIFrame GUIFrame Test frame.setSize 400 300 frame.setVisible true Using CardLayout The CardLayout layout manager lays .

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