tailieunhanh - Java Swing phần 2

Chạy chương trình này và nhấn nút sản xuất đầu ra sau đây:ChangeEvent! ChangeEvent! Khi nút được phát hành, sản lượng bổ sung sau được sản xuất: ActionEvent! ChangeEvent! Những sự kiện thay đổi ban đầu là bị sa thải, | Java Swing - O Reilly import . import . import . import . public class JButtonEvents public static void main String args JButton jb new JButton Press Me new ActionListener public void actionPerformed ActionEvent ev ActionEvent new ItemListener public void itemStateChanged ItemEvent ev ItemEvent new ChangeListener public void stateChanged ChangeEvent ev ChangeEvent JFrame f new JFrame new BasicWindowMonitor .add jb true Running this program and pressing the button produces the following output ChangeEvent ChangeEvent When the button is released the following additional output is produced ActionEvent ChangeEvent The initial change events are fired indicating that the button has been armed and pressed. When the button is released the action event is fired along with another change event to indicate that the button is no longer pressed. Pressing the button a second time results in only a single change event followed by the action event and change event when the button is released. This is because the button s armed property remains set to true after the button is clicked. This property only gets set to false again if you hold the mouse button down and then move the cursor away from the button. If the button is released while the pointer is no longer over the button no ActionEvent will be fired. In practice you will typically only be interested in the ActionEvents fired by a JButton. Constructors public JButton Creates a button with no image or text. - 100 - Java Swing - O Reilly public JButton Icon icon Creates a button displaying the specified icon. public JButton String text Creates a button displaying the specified text. public JButton String text Icon icon Creates a button displaying the specified text and icon. User Interface .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
crossorigin="anonymous">
Đã 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.