-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTrashCan.java
More file actions
28 lines (23 loc) · 768 Bytes
/
Copy pathTrashCan.java
File metadata and controls
28 lines (23 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import javax.swing.*;
import java.awt.*;
public class TrashCan extends JPanel {
private int x;
private int y;
public TrashCan(int x, int y){
this.x = x;
this.y = y;
}
public void draw(Graphics g){
g.setColor(Color.gray);
g.fillRect(this.x, this.y, 40, 45);
g.fillRect(this.x, this.y-15, 40, 10 );
}
public void delete(Block b){
Rectangle trashcan = new Rectangle(x+30, y, 40, 45);
Rectangle block = new Rectangle(b.getX1(), b.getY1(), b.getX2()-b.getX1(), b.getY2()-b.getY1());
if(trashcan.intersects(block)){
DataSource.getInstance().getBlocksRunInstance().remove(b);
DataSource.getInstance().getBlockArrayInstance().remove(b);
}
}
}