zoukankan      html  css  js  c++  java
  • java中的闰年的计算

    package aab;

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;

    /**
     * <p>Title: the leap year</p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2006</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */

    public class Frame1 extends JFrame {
      JPanel contentPane;
      BorderLayout borderLayout1 = new BorderLayout();
      TextArea textArea1 = new TextArea();

      //Construct the frame
      public Frame1() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
      }
      //Component initialization
      private void jbInit() throws Exception  {
        contentPane = (JPanel) this.getContentPane();


        int year=1989;
        if((year%4==0&&year%100!=0)||(year%400==0))
          textArea1.append(year+"is a leap year.\n");
          else
            textArea1.append(year+"is not a leap year.\n");


        contentPane.setLayout(borderLayout1);
        this.setSize(new Dimension(400, 300));
        this.setTitle("Frame Title");
        contentPane.add(textArea1, BorderLayout.CENTER);
      }
      //Overridden so we can exit when window is closed
      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          System.exit(0);
        }
      }
    }

  • 相关阅读:
    [ python ] 函数的参数
    [ python ] 文件读写操作
    [ python ] 集合的使用
    [ python ] 购物系统
    [ python ] 字符编码
    [ python ] 字典的使用
    [ python ] 列表和元组
    [ python ] 字符串的操作及作业题
    [ python ] 格式化输出、字符集、and/or/not 逻辑判断
    [ python ] 变量及基础的数据类型
  • 原文地址:https://www.cnblogs.com/josn1984/p/370107.html
Copyright © 2011-2022 走看看