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

📄 example7_4.java

📁 主要是对于JAVA的编程的基本语言 希望能够帮得上你。
💻 JAVA
字号:
package ForTest;

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

public class Example7_4 {	
	public static void main(String[] args) {
		GraphicsDemo myGraphicsDemo=new GraphicsDemo();
	}
}

class ShapePanel extends JPanel{
	ShapePanel(){
		this.setBackground(Color.WHITE);
	}
	
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		this.setBackground(Color.YELLOW);
		g.setXORMode(Color.RED);
		g.setColor(Color.GREEN);
		g.fillRect(20,20, 80, 40);
		g.setColor(Color.YELLOW);
		g.fillRect(60,20, 80,40);
		g.setColor(Color.GREEN);
		g.fillRect(20,70,80,40);
		g.fillRect(60,70,80,40);
		g.setColor(Color.GREEN);
		g.drawLine(80, 100, 180,200);
		g.drawLine(100, 100, 200,200);
		
		g.drawLine(140, 140, 220,220);
		g.setColor(Color.YELLOW);
		g.drawLine(20, 30, 160,30);
		g.drawLine(20, 75, 160,75);		
	}
}

class GraphicsDemo extends JFrame{
	public GraphicsDemo(){
		this.getContentPane().add(new ShapePanel());
		this.setTitle("基本绘图方法演示");
		this.setSize(300,300);
		this.setVisible(true);
	}
}

⌨️ 快捷键说明

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