TAILIEUCHUNG - Thinking in Java 4th Edition phần 10

mong muốn kết quả. Mặc dù sự bất tiện này, một giao diện sẽ đảm bảo rằng các phương pháp được thực hiện. Một cách khác cải thiện để đảm bảo rằng bạn đang ở trong thực tế, trọng một phương pháp là sử dụng được xây dựng trong chú thích Override trong đoạn code trên. | Simpo PDF Merge and Split Unregistered Version - http desired results. Despite the inconvenience an interface will guarantee that the methods are properly implemented. An improved alternative way to guarantee that you are in fact overriding a method is to use the built-in @Override annotation in the code above. Exercise 9 5 Starting with create a program with the full functionality of . Tracking multiple events To prove to yourself that these events are in fact being fired it s worth creating a program that tracks behavior in a JButton beyond whether it has been pressed. This example also shows you how to inherit your own button object from In the code below the MyButton class is an inner class of TrackEvent so MyButton can reach into the parent window and manipulate its text fields which is necessary in order to write the status information into the fields of the parent. Of course this is a limited solution since MyButton can be used only in conjunction with TrackEvent. This kind of code is sometimes called highly coupled gui Show events as they happen. import . import . import . import . import static . public class TrackEvent extends JFrame private HashMap String JTextField h new HashMap String JTextField private String event focusGained. focusLost keyPressed keyReleased keyTyped mouseClicked mouseEntered mouseExited mousePressed mouseReleased mouseDragged mouseMoved . private MyButton bl neW MyButton testl b2 new MyButton test2 class MyButton extends JButton void report String field String msg field .setText msg FocusListener fl new FocusListener public void focusGained FocusEvent e report focusGained . public void focusLost FocusEvent e report focusLost KeyListener kl new KeyListener public void keyPressed KeyEvent e report keyPressed .

TỪ KHÓA LIÊN QUAN
Đã 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.