16.2
Posted 功夫茶茶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了16.2相关的知识,希望对你有一定的参考价值。
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 }
效果:
以上是关于16.2的主要内容,如果未能解决你的问题,请参考以下文章