📄 lgpaint.java
字号:
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
public class lgpaint extends Applet implements Runnable {
public lgpaint() {
m_draw = null;
once = true;
begin = false;
running = false;
started = false;
stamp = false;
menu = new Panel();
choices = new Choice();
mode = new Choice();
clear = new Button("Clear");
help = new Button("Help");
}
public void buildChoices(Choice choice) {
for (int i = 1; i <= 10; i++)
choice.addItem((new Integer(i)).toString());
}
public void destroy() {
if (m_draw != null) {
m_draw.stop();
m_draw = null;
}
running = false;
}
public String getAppletInfo() {
return "For Demo Applet";
}
public void init() {
setLayout(new BorderLayout());
d = size();
resize(d.width, d.height);
requestFocus();
}
public boolean mouseEnter(Event event, int i, int j) {
getAppletContext().showStatus(
"Applet by Lawrence Goetz - LawrenceGoetz.com");
return true;
}
public boolean mouseExit(Event event, int i, int j) {
getAppletContext().showStatus("");
return true;
}
public void paint(Graphics g) {
pad.repaint();
}
public void pause(int i) {
try {
Thread.sleep(i);
} catch (InterruptedException _ex) {
}
}
public void run() {
boolean flag = true;
running = true;
started = true;
pad.setup();
pad.repaint();
}
public void start() {
if (m_draw == null) {
m_draw = new Thread(this);
started = false;
}
if (once) {
pad = new lgcanvas(d.width, d.height, this, choices, mode);
menu.setBackground(Color.gray);
buildChoices(choices);
mode.addItem("Pen");
mode.addItem("Stamp");
mode.addItem("Background");
choices.select(0);
mode.select(0);
menu.add(help);
menu.add(clear);
menu.add(new Label("Mode", 2));
menu.add(mode);
menu.add(new Label("Choice", 2));
menu.add(choices);
add("North", menu);
add("Center", pad);
once = false;
new paintselect(pad, choices, mode, help, clear);
}
begin = true;
if (!m_draw.isAlive())
m_draw.start();
}
public void stop() {
if (m_draw != null) {
m_draw.stop();
m_draw = null;
}
running = false;
}
public void update(Graphics g) {
paint(g);
}
private Thread m_draw;
private String filename;
private lgcanvas pad;
private boolean once;
private Dimension d;
private boolean begin;
private boolean running;
private boolean started;
private boolean stamp;
private Panel menu;
private Choice choices;
private Choice mode;
private Button clear;
private Button help;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -