File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -11,17 +11,21 @@ public class DrawRect extends JPanel {
11
11
ArrayList <Integer > arr ;
12
12
13
13
public DrawRect (ArrayList <Integer > heights ) {
14
+ // Shallow Cloning
14
15
arr = heights ;
15
16
}
17
+
18
+ // Changing the instance variable so that paint component is called
16
19
public void setArr (ArrayList <Integer > newArr ) {
17
20
arr = newArr ;
18
- }
21
+ }
22
+
19
23
@ Override
20
24
public void paintComponent (Graphics g ) {
21
25
Graphics2D graphics = (Graphics2D ) g ;
22
26
super .paintComponent (graphics );
23
27
graphics .setColor (RECT_COLOR );
24
- for (int i = 0 , x = 5 ; x <= 1600 ; x += WIDTH + 5 , i ++) {
28
+ for (int i = 0 , x = 10 ; x <= 1580 ; x += WIDTH + 4 , i ++) {
25
29
int y = arr .get (i );
26
30
graphics .fillRect (x , y , WIDTH , HEIGHT );
27
31
}
You can’t perform that action at this time.
0 commit comments