zoukankan      html  css  js  c++  java
  • 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 }
    Exercise16_2.java

    效果:

  • 相关阅读:
    离场飞越转弯全家福
    画一个PBN大角度飞越转弯保护区
    画一个小角度飞越转弯保护区
    Point Estimation
    Random variable
    心流
    Survey sampling
    Distribution
    数学分析总结
    topological space
  • 原文地址:https://www.cnblogs.com/wanjiang/p/5635419.html
Copyright © 2011-2022 走看看