📄 kumaapp.java
字号:
/*
* Kuma.java
*
* Copyright 1999 JJKING Software, Junichi Ito <jun1@mailhost.net>
* Permission to use, copy, modify, and distribute this software and its
* documentation without fee for NON-COMMERCIAL is free.
*/
import com.sun.kjava.*;
/**
* This is the main application.
*
* @version 1.0 1999/10/2
*/
public class KumaApp extends Spotlet
{
/**
* The GUI components.
*/
Button comeButton;
Button byeButton;
Button exitButton;
/**
* The animation characters.
*/
Kuma kuma;
/**
* The bounds of animation field.
*/
static Rectangle fieldBounds = new Rectangle(2, 2, 156, 136);
/**
* The animation manager.
*/
AnimManager animMgr;
/**
* Creates a spotlet and registers its event handlers.
*/
public static void main(String[] args)
{
(new KumaApp()).register(NO_EVENT_OPTIONS);
}
/**
* Create screen and start programs.
*/
public KumaApp()
{
// GUI components
comeButton = new Button("Come on", 8, 142);
byeButton = new Button("Bye", 56, 142);
exitButton = new Button("Exit", 136, 142);
// initialize animation manager
animMgr = new AnimManager(fieldBounds);
// paint screen
Graphics g = Graphics.getGraphics();
paint(g);
}
/**
* Clears and draw screen.
*/
void paint(Graphics g)
{
g.clearScreen();
update(g);
}
/**
* Draw screen.
*/
void update(Graphics g)
{
// border
g.drawBorder(fieldBounds.x
, fieldBounds.y
, fieldBounds.width
, fieldBounds.height
, g.PLAIN
, g.borderType(4, 0, 1));
// GUI components
comeButton.paint();
byeButton.paint();
exitButton.paint();
}
/**
* Handles pen down event.
*/
public void penDown(int x, int y)
{
if (exitButton.pressed(x,y)) {
System.exit(0);
}
else if (comeButton.pressed(x,y)) {
try {
Kuma newKuma = new Kuma();
animMgr.add(newKuma);
kuma = newKuma;
}
catch(AnimException ex) {}
}
else if (byeButton.pressed(x,y)) {
if (kuma != null) { kuma.bye(); }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -