-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathList.java
More file actions
23 lines (20 loc) · 717 Bytes
/
Copy pathList.java
File metadata and controls
23 lines (20 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.awt.Component;
import javax.swing.JPanel;
public class List extends JPanel {
public List() {
this.setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS));
// Optional: set background color if you want
// this.setBackground(java.awt.Color.WHITE);
}
public void updateNumbers() {
Component[] listItems = this.getComponents();
for (int i = 0; i < listItems.length; i++) {
if (listItems[i] instanceof Task) {
((Task) listItems[i]).changeIndex(i + 1);
}
}
}
public void add(Task task) {
super.add(task); // ✅ Call JPanel's add method, not your own
}
}