📄 clearal.java
字号:
package graphInterface;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ClearAL implements ActionListener{
private JPanel sourcePanel;
private JPanel infoPanel;
public ClearAL(JPanel sp, JPanel ip) {
sourcePanel = sp;
infoPanel = ip;
}
public void actionPerformed(ActionEvent ae) {
// 清除对象面板内容
Graphics sgra = sourcePanel.getGraphics();
sgra.setColor(sourcePanel.getBackground());
sgra.fillRect(0, 0, 1000, 1000);
// 清除信息面板内容
Graphics igra = infoPanel.getGraphics();
igra.setColor(infoPanel.getBackground());
igra.fillRect(0, 0, 1000, 1000);
// 清除对象面板的鼠标监听器
MouseListener[] al = sourcePanel.getMouseListeners();
for (int i = 0; i < al.length; ++i) {
sourcePanel.removeMouseListener(sourcePanel.getMouseListeners()[i]);
sourcePanel.removeMouseMotionListener(sourcePanel
.getMouseMotionListeners()[i]);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -