exercise20_3.java

来自「java程序设计 机械工业出版社 书籍代码」· Java 代码 · 共 34 行

JAVA
34
字号
// Exercise20_3.java: Display calendar and clock
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;

public class Exercise20_3 extends JApplet {
  public void init() {
    this.getContentPane().add(new CalendarPanel(), BorderLayout.CENTER);
    this.getContentPane().add(new WorldClock(), BorderLayout.EAST);
  }

  // Main method
  public static void main(String[] args) {
    // Create a frame
    JFrame frame = new JFrame(
      "Calendar and Clock");

    // Create an instance of the applet
    Exercise20_3 applet = new Exercise20_3();

    // Add the applet instance to the frame
    frame.getContentPane().add(applet, BorderLayout.CENTER);

    // Invoke init() and start()
    applet.init();
    applet.start();

    // Display the frame
    frame.pack();
    frame.setVisible(true);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?