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

📄 drawpan.java

📁 一个简单的画板applet。适合初学java的coder参考
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

public class Drawpan extends JApplet
{
	static final long serialVersionUID = 7653;
	private LinkedList <LinkedList<Point>> DrawAction = new LinkedList<LinkedList<Point>>();
	public void paint(Graphics g)
	{
		ListIterator iter = DrawAction.listIterator();
		while(iter.hasNext())
		{
			LinkedList ll = (LinkedList)iter.next();
			ListIterator iter2 = ll.listIterator();
			int x1=-1,y1=-1;
			while(iter2.hasNext())
			{
				Point temp = ((Point)iter2.next());
				if (x1!=-1 || y1!=-1)
					g.drawLine(x1, y1, temp.x, temp.y);
				
				x1 = temp.x;
				y1 = temp.y;
			}
		}
		
	}
	public void init()
	{
		DrawAction.push(new LinkedList<Point>());
		this.addMouseMotionListener(
				new MouseMotionListener()
				{
					public void mouseDragged(MouseEvent e) 
					{
						(DrawAction.getFirst()).push(e.getPoint());
						repaint();
					}
					public void mouseMoved(MouseEvent e) 
					{
					}
				});
		this.addMouseListener(
				new java.awt.event.MouseListener()
				{
					public void mouseClicked(MouseEvent e) {}
	           
					public void mouseEntered(MouseEvent e) {} 
	           
					public void mouseExited(MouseEvent e) {} 
	          
					public void mousePressed(MouseEvent e) 
					{
						DrawAction.push(new LinkedList<Point>());
					} 
	           
					public void mouseReleased(MouseEvent e) {}  

				});
	}
	
}

// <applet code=Drawpan width=200 height=200></applet>

⌨️ 快捷键说明

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