VietTuts

Tự Học Lập Trình Online

  • Home
  • Java
  • Servlet
  • JSP
  • Struts2
  • Hibernate
  • Spring
  • Python
  • Java WS
  • MyBatis
  • Eclipse
  • VBA
  • Web
    • JavaScript
    • JQUERY
    • JSON
    • AJAX
    • PHP
    • CSS
    • HTML
  • SQL
    • MySQL
    • SQL Server
  • Misc
    • Phần mềm tiện ích
    • Selenium Test
    • Lập trình C
    • Lập trình C++
  • Tuyển Dụng
Java Cơ Bản Các Khái Niệm Java OOPs Java String Xử Lý Ngoại Lệ Các Lớp Lồng Nhau

Java AWT

AWT trong java Xử lý sự kiện Java AWT Button trong Java AWT Label trong Java AWT TextField trong Java AWT TextArea trong Java AWT CheckBox trong Java AWT CheckBoxGroup trong Java AWT Choice trong Java AWT List trong Java AWT Canvas trong Java AWT Scrollbar trong Java AWT MenuItem và Menu trong Java AWT PopupMenu trong Java AWT Panel trong Java AWT Dialog trong Java AWT Toolkit trong Java AWT ActionListener trong Java AWT MouseListener trong Java AWT MouseMotionListener trong Java AWT ItemListener trong Java AWT KeyListener trong Java AWT WindowListener trong Java AWT Close Window trong Java AWT Các lớp Adapter trong Java AWT
Java Swing Java I/O Ví Dụ Java I/O Lập Trình Mạng Với Java Java Date Chuyển Đối Kiểu Dữ Liệu Java Collections Java JDBC Các Tính Năng Mới Trong Java Bài Tập Java Có Lời Giải Câu Hỏi Phỏng Vấn Java

WindowListener trong Java AWT


KeyListener trong Java AWT
Close Window trong Java AWT

Java WindowListener được gọi bất cứ khi nào bạn thay đổi trạng thái của window. Interface WindowListener thuộc về package java.awt.event. Nó có 7 phương thức.

Các phương thức của interface WindowListener

Interface WindowListener có 7 phương thức được đưa ra như dưới đây.

public abstract void windowActivated(WindowEvent e);
public abstract void windowClosed(WindowEvent e);
public abstract void windowClosing(WindowEvent e);
public abstract void windowDeactivated(WindowEvent e);
public abstract void windowDeiconified(WindowEvent e);
public abstract void windowIconified(WindowEvent e);
public abstract void windowOpened(WindowEvent e);

Ví dụ về Java WindowListener trong Java AWT

package vn.viettuts.awt;

import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

public class WindowListenerExample1 extends Frame 
        implements WindowListener {
    private Label label;
    public WindowListenerExample1() {
        label = new Label();
        label.setBounds(20, 50, 200, 20);
        addWindowListener(this);
        add(label);
        setSize(400, 400);
        setLayout(null);
        setVisible(true);
    }

    public void windowActivated(WindowEvent arg0) {
        label.setText("activated");
    }

    public void windowClosed(WindowEvent arg0) {
        System.out.println("closed");
    }

    public void windowClosing(WindowEvent arg0) {
        System.out.println("closing");
        dispose();
    }

    public void windowDeactivated(WindowEvent arg0) {
        label.setText("deactivated");
    }

    public void windowDeiconified(WindowEvent arg0) {
        System.out.println("deiconified");
    }

    public void windowIconified(WindowEvent arg0) {
        System.out.println("iconified");
    }

    public void windowOpened(WindowEvent arg0) {
        System.out.println("opened");
    }

    public static void main(String[] args) {
        new WindowListenerExample1();
    }
}

Kết quả:

Ví dụ WindowListener trong Java AWT
KeyListener trong Java AWT
Close Window trong Java AWT


Recent Updates

Set trong PythonPython là gì? - giới thiệu ngôn ngữ lập trình PythonTuple trong PythonDictionary trong PythonList trong PythonHọc Lập Trình Online - VietTuts.VnKiểu dữ liệu Number trong PythonChuỗi (String) trong PythonHàm Dictionary values() trong PythonHàm Dictionary update() trong PythonHàm Dictionary setdefault() trong PythonHàm Dictionary keys() trong Python

VietTuts on facebook

Học Java Cơ Bản Đến Nâng Cao - VietTuts.Vn

Danh sách bài học

Học java
Học servlet
Học jsp
Học Hibernate
Học Struts2
Học Spring
Học SQL

Câu hỏi phỏng vấn

201 câu hỏi phỏng vấn java
25 câu hỏi phỏng vấn servlet
75 câu hỏi phỏng vấn jsp
52 câu hỏi phỏng vấn Hibernate
70 câu hỏi phỏng vấn Spring
57 câu hỏi phỏng vấn SQL

About VietTuts.Vn

Hệ thống bài học trên VietTuts.Vn bao gồm các bài lý thuyết và thực hành về các công nghệ java và công nghệ web. Các bài lý thuyết trên hệ thống VietTuts.Vn được tham khảo và tổng hợp từ các trang http://javatpoint.com, http://www.tutorialspoint.com, http://docs.oracle.com/en …

Scroll back to top

Copyright © 2016 VietTuts.Vn all rights reserved. | VietTuts.Vn team | Liên hệ | Chính sách - riêng tư | sitemap.html | sitemap_index.xml