资源简介
23070219.rar
代码片段和文件信息
//: BangBean.java
// A graphical Bean
package bangbean;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
public class BangBean extends Canvas
implements Serializable {
protected int xm ym;
protected int cSize = 20; // Circle size
protected String text = “Bang!“;
protected int fontSize = 48;
protected Color tColor = Color.red;
protected ActionListener actionListener;
public BangBean() {
addMouseListener(new ML());
addMouseMotionListener(new MML());
}
public int getCircleSize() { return cSize; }
public void setCircleSize(int newSize) {
cSize = newSize;
}
public String getBangText() { return text; }
public void setBangText(String newText) {
text = newText;
}
public int getFontSize() { return fontSize; }
public void setFontSize(int newSize) {
fontSize = newSize;
}
public Color getTextColor() { return tColor; }
public void setTextColor(Color newColor) {
tColor = newColor;
}
public void paint(Graphics g) {
g.setColor(Color.black);
g.drawOval(xm - cSize/2 ym - cSize/2
cSize cSize);
}
// This is a unicast listener which is
// the simplest form of listener management:
public void addActionListener (
ActionListener l)
throws TooManyListenersException {
if(actionListener != null)
throw new TooManyListenersException();
actionListener = l;
}
public void removeActionListener(
ActionListener l) {
actionListener = null;
}
class ML extends MouseAdapter {
public void mousePressed(MouseEvent e) {
Graphics g = getGraphics();
g.setColor(tColor);
g.setFont(
new Font(
“TimesRoman“ Font.BOLD fontSize));
int width =
g.getFontMetrics().stringWidth(text);
g.drawString(text
(getSize().width - width) /2
getSize().height/2);
g.dispose();
// Call the listener‘s method:
if(actionListener != null)
actionListener.actionPerformed(
new ActionEvent(BangBean.this
ActionEvent.ACTION_PERFORMED null));
}
}
class MML extends MouseMotionAdapter {
public void mouseMoved(MouseEvent e) {
xm = e.getX();
ym = e.getY();
repaint();
}
}
public Dimension getPreferredSize() {
return new Dimension(200 200);
}
// Testing the BangBean:
public static void main(String[] args) {
BangBean bb = new BangBean();
try {
bb.addActionListener(new BBL());
} catch(TooManyListenersException e) {}
frame aframe = new frame(“BangBean Test“);
aframe.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
aframe.add(bb BorderLayout.CENTER);
aframe.setSize(300300);
aframe.setVisible(true);
}
// During testing send action information
/
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..AD..R 0 2002-11-03 11:36 Java编程思想
..AD..R 0 2002-10-27 10:10 Java编程思想\code1
..AD..R 0 2002-10-27 10:10 Java编程思想\code1\bangbean
文件 0 2001-01-20 04:59 Java编程思想\code1\bangbean\1.files
文件 3182 2001-01-20 04:59 Java编程思想\code1\bangbean\BangBean.java
..AD..R 0 2002-10-27 10:10 Java编程思想\code1\c02
文件 0 2001-01-20 04:59 Java编程思想\code1\c02\1.files
文件 846 2001-01-20 04:59 Java编程思想\code1\c02\Property.java
..AD..R 0 2002-10-27 10:10 Java编程思想\code1\c03
文件 0 2001-01-20 04:59 Java编程思想\code1\c03\23.files
文件 7893 2001-01-20 04:59 Java编程思想\code1\c03\AllOps.java
文件 534 2001-01-20 04:59 Java编程思想\code1\c03\Assignment.java
文件 461 2001-01-20 04:59 Java编程思想\code1\c03\AutoInc.java
文件 2041 2001-01-20 04:59 Java编程思想\code1\c03\BitManipulation.java
文件 876 2001-01-20 04:59 Java编程思想\code1\c03\Bool.java
文件 557 2001-01-20 04:59 Java编程思想\code1\c03\BreakAndContinue.java
文件 627 2001-01-20 04:59 Java编程思想\code1\c03\CastingNumbers.java
文件 236 2001-01-20 04:59 Java编程思想\code1\c03\CommaOperator.java
文件 220 2001-01-20 04:59 Java编程思想\code1\c03\EqualsMethod.java
文件 264 2001-01-20 04:59 Java编程思想\code1\c03\EqualsMethod2.java
文件 248 2001-01-20 04:59 Java编程思想\code1\c03\Equivalence.java
文件 1104 2001-01-20 04:59 Java编程思想\code1\c03\LabeledFor.java
文件 702 2001-01-20 04:59 Java编程思想\code1\c03\LabeledWhile.java
文件 345 2001-01-20 04:59 Java编程思想\code1\c03\ListCharacters.java
文件 742 2001-01-20 04:59 Java编程思想\code1\c03\Literals.java
文件 1505 2001-01-20 04:59 Java编程思想\code1\c03\MathOps.java
文件 333 2001-01-20 04:59 Java编程思想\code1\c03\Overflow.java
文件 382 2001-01-20 04:59 Java编程思想\code1\c03\Passob
文件 672 2001-01-20 04:59 Java编程思想\code1\c03\RandomBounds.java
文件 803 2001-01-20 04:59 Java编程思想\code1\c03\ShortCircuit.java
............此处省略1594个文件信息
相关资源
- DenoiseMethods.rar
- 搭建步骤和SSTap.rar
- 米花同城6.6.9全开源解密包含小程序代
- MahjongClient.zip
- QQ信息搜索测试版QQ空间加密破解相册
- 组态王7.5SP2无限点破解.zip
- Operating-System-Concepts-9th2012.12(Abraham
- MCGS6.2开发和运行无限点WEB版无限客户
- 全国GIS水平考试一级辅导教材(1)
- 01BBS论坛系统.rar
- 3f26db3f6200470f34b5574e55642937-副本.rar
- General_CMS_Chn_V3.0.9.2.T.20120929.rar
- EtherCATSlaveStackCodeTool.rar
- zw_xinghen1993-9700835-售票系统.zip
- src.zip
- zw_微信发送或转发任意语音消息V1.6
- electric-circuits-10th-edition-solutions.pdf
- 大型通信网络仿真系统.doc
- 亿图9.4破解版.zip
- 3c58da0651ede876d073661aff58f07d.rar
- xds100_drivers_xds100v1驱动_xds100v2驱动_x
- AlteraFPGA应用设计》配套资料.rar
- caj
- 21世纪软件工程专业规划教材软件工程
- NamelessCotrunQuad_V1.0-master.zip
- 裸奔三部曲全书20110101.rar
- dict.txt
- 读秀一键获取阅读全文V1.0.rar
- MKcms5.0影视源码完美修复版电脑手机自
- 信息安全数学基础第四章.docx
评论
共有 条评论