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

📄 debugwintest.java

📁 Java2核心技术卷一 配套源码,看了还不错
💻 JAVA
字号:
/**
 * @version 1.20 06 May 1997
 * @author Cay Horstmann
 */


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

public class DebugWinTest extends JFrame 
   implements ActionListener
{  public DebugWinTest()
   {  setTitle("DebugWinTest");
      setSize(400, 400);
      addWindowListener(new WindowAdapter()
         {  public void windowClosing(WindowEvent e)
            {  System.exit(0);
            }
         } );

      pane = new JPanel();

      yellowButton = new JButton("Yellow");
      pane.add(yellowButton);
      yellowButton.addActionListener(this); 

      blueButton = new JButton("Blue");
      pane.add(blueButton);
      blueButton.addActionListener(this); 

      redButton = new JButton("Red");
      pane.add(redButton);
      redButton.addActionListener(this);

      getContentPane().add(pane);
   }
   
   public void actionPerformed(ActionEvent evt)
   {  dw.print("Event = " + evt);
      Object source = evt.getSource();
      Color color = getBackground();
      if (source == yellowButton) color = Color.yellow;
      else if (source == blueButton) color = Color.blue;
      else if (source == redButton ) color = Color.red;
      setBackground(color);
      repaint();
   }
   
   public static void main(String[] args)
   {  JFrame f = new DebugWinTest();
      f.show();
   }

   private JPanel pane;
   private JButton yellowButton;
   private JButton blueButton;
   private JButton redButton; 
   private DebugWin dw = new DebugWin();
}

⌨️ 快捷键说明

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