⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 awthello.java

📁 java 完全探索的随书源码
💻 JAVA
字号:
// AWTHello.java

import java.awt.*;
import java.awt.event.*;

class AWTHello extends Frame implements ActionListener
{
   Button b;

   static String [] labels =
   {
      "Hello! Welcome to AWT!",
      "You cannot assign icons to AWT buttons."
   };

   int nextLabel;

   AWTHello (String title)
   {
      super (title);

      addWindowListener (new WindowAdapter ()
                         {
                             public void windowClosing (WindowEvent e)
                             {
                                System.exit (0);
                             }
                         });

      Panel p = new Panel ();
      b = new Button (labels [nextLabel++]);
      b.addActionListener (this);
      p.add (b);
      add (p);

      setSize (300, 100);
      setVisible (true);
   }

   public void actionPerformed (ActionEvent e)
   {
      b.setLabel (labels [nextLabel++]);
      validate ();
      nextLabel %= labels.length;
   }

   public static void main (String [] args)
   {
      new AWTHello ("Hello, AWT Version");
   }
}

⌨️ 快捷键说明

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