?? drawpan.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 + -