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

📄 xor.java

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

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

class XORPanel extends JPanel
{  XORPanel()
   {  setBackground(Color.black);
   }

   public void paintComponent(Graphics g)
   {  super.paintComponent(g);
      g.setColor(Color.red);
      g.fillRect(10, 10, 80, 30);
      g.setColor(Color.green);
      g.fillRect(50, 20, 80, 30);
      g.setColor(Color.blue);
      g.fillRect(130, 40, 80, 30);
      g.setXORMode(Color.green);
      g.fillRect(90, 30, 80, 30);
   }
}

class XORFrame extends JFrame
{  public XORFrame()
   {  setTitle("XOR");
      setSize(300, 200);
      addWindowListener(new WindowAdapter()
         {  public void windowClosing(WindowEvent e)
            {  System.exit(0);
            }
         } );
      Container contentPane = getContentPane();
      contentPane.add(new XORPanel());
   }
}

public class XOR
{  public static void main(String[] args)
   {  JFrame frame = new XORFrame();
      frame.show();  
   }
}

                        

⌨️ 快捷键说明

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