码迷,mamicode.com
首页 > 其他好文 > 详细

16.2

时间:2016-07-02 15:58:36      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

技术分享
 1 import javax.swing.*;
 2 import java.awt.*;
 3 import java.awt.event.*;
 4 
 5 public class Exercise16_2 extends JFrame
 6     implements ComponentListener {
 7   public Exercise16_2() {
 8     // Set the window title
 9     setTitle("Exercise16_2");
10 
11     // Register the frame as a listener for component events
12     this.addComponentListener(this);
13   }
14 
15   /** Main method */
16   public static void main(String[] args) {
17     Exercise16_2 frame = new Exercise16_2();
18     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
19     frame.setSize(100, 80);
20     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
21     frame.setLocationRelativeTo(null); // Center the frame
22     frame.setVisible(true);
23   }
24 
25   public void componentMoved(ComponentEvent e) {
26     System.out.println("Component moved");
27   }
28 
29   public void componentHidden(ComponentEvent e) {
30     System.out.println("Component hidden");
31   }
32 
33   public void componentResized(ComponentEvent e) {
34     System.out.println("Component resized");
35   }
36 
37   public void componentShown(ComponentEvent e) {
38     System.out.println("Component shown");
39   }
40 }
Exercise16_2.java

效果:

技术分享

 

16.2

标签:

原文地址:http://www.cnblogs.com/wanjiang/p/5635419.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!