📄 circlemodel.java
字号:
import java.awt.event.*;import java.util.*;public class CircleModel { /** Property radius. */ private double radius = 20; /** Property filled. */ private boolean filled; /** Property color. */ private java.awt.Color color; /** Utility field used by event firing mechanism. */ private ArrayList actionListenerList; public double getRadius() { return radius; } public boolean isFilled() { return filled; } public java.awt.Color getColor() { return color; } public void setRadius(double radius) { this.radius = radius; // Notify the listener for the change on radius processEvent( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "radius")); } public void setFilled(boolean filled) { this.filled = filled; // Notify the listener for the change on filled processEvent( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "filled")); } public void setColor(java.awt.Color color) { this.color = color; // Notify the listener for the change on color processEvent( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "color")); } /** Register an action event listener */ public synchronized void addActionListener(ActionListener l) { ArrayList list = actionListenerList == null ? new ArrayList(2) : (ArrayList)actionListenerList.clone(); if (!list.contains(l)) { list.add(l); actionListenerList = list; } } /** Remove an action event listener */ public synchronized void removeActionListener(ActionListener l) { if (actionListenerList != null && actionListenerList.contains(l)) actionListenerList.remove(l); } /** Fire TickEvent */ private void processEvent(ActionEvent e) { ArrayList list; synchronized (this) { list = (ArrayList)actionListenerList.clone(); } for (int i = 0; i < list.size(); i++) { ActionListener listener = (ActionListener)list.get(i); listener.actionPerformed(e); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -