help please Java, I will upvote.
Posted: Fri Apr 29, 2022 7:06 am
help please Java, I will upvote.
The following GUI application displays four colored filled circles at the four corners of the square. Every time the user clicks on the panel, one of the circles changes to a random color. First, the top left, then the top right, then the bottom left and then the bottom right and so on. However, there are several errors and/or missing lines. For each of the specified lines below choose the correct line. 6 public class Drawing Panel3 extends JPanel { ArrayList<Circle> things = new ArrayList<Circle>(); int x = 50, y = 50, 1 = 100, radius = 50, num = 0; public Drawing Panel3 () { this. set Background (Color.yellow); this. addMouseListener(); things.add(new Circle(x, y)); //top left things.add(new Circle(x , y));// top right things.add(new Circle(x, y)); // bottom? things.add(new Circle(x, y));//bottom } class Circle { int x = 100; int y = 100; Color c = new Color (1, 1, 1); TO 12 14 16 18 22 24 26 28 30 public Circle (int x, int y) { this.x = x; this.y = y; } public void setColor (Color c) { C = new Color (c); } public void draw(Graphics g) { g. set Color (c); g. filloval(x, y, radius, radius); } } class ClickListener extends MouseAdapter { public void mouseClicked (MouseEvent e) { Color c = new Color ((int) (Math.random() * 256), (int) (Math.random() *256), (int) (Math.random() *256)); things.setColor (c); num++; if (num == 4) num = -1; repaint(); } } @Override protected void paint Component (Graphics g) { super.paint Component(g): g. drawRect(x, y, 1, 1); for (int i = 0; i < things [1]; i++) { things.draw(g); 32 34 36 38 40 42 44 46 } } Line 6. should be
Line 6. should be Othis.addMouseListener(new ClickListener(); Othis.addMouseListener(); Othis.addMouseListener(new MouseListener(ClickListener())); Othis.addMouseListener(this); o this.addMouseListener(new MouseAdapter(new ClickListener())); Othis.addMouseListener(new MouseAdapter()); Line 7. should be Othings.add(new Circle(x-radius/2, y- radius/2)); Othings.add(new Circle((x + 1) - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, (y + 1) - radius/2)); Othings.add(new Circle(x - radius, (y + 1) - radius); Othings.add(new Circle(x, y)); - Line 8. should be Othings.add(new Circle((x + 1) - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, y- radius/2)); Othings.add(new Circlelv - radius/2, (y + 1) - radius/2)); Ā Othings.add(new Circle((x + 1) - radius, y -
Line 8. should be Othings.add(new Circle((x + 1) - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, y- radius/2)); Othings.add(new Circle(x - radius/2, (y + 1) - radius/2)); Othings.add(new Circle((x + 1) - radius, y - radius)); Othings.add(new Circle(x, y)); Line 9. should be Othings.add(new Circle(x - radius/2, (y + 1) - radius/2)); Othings.add(new Circle((x + 1) - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, (y + 1) - radius/2)); things.add(new Circle(x - radius, (y + 1) - radius)); Othings.add(new Circle(x, y));
Line 10. should be Othings.add(new Circle((x + 1) - radius/2, (y + 1) - radius/2)); Othings.add(new Circle((x + 1) - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, (y + 1) - radius/2)); things.add(new Circle((x + 1) - radius, (y + 1) - radius)); Othings.add(new Circle(x, y)); Line 33. should be Othings.get(num).setColor(c); Othings.get(num).setColor(new Color); Othings.get(this).setColor(c); things.get(num-1).setColor(c); Othings.get(thing.size()-1).setColor(c); Line 36. should be = = Onum = 0; Onum = 1; Onum = things.size(-1); Onum = size -1; Onum = num-1; = = Л
Line 36. should be = Onum = 0; Onum = 1; Onum = things.size(-1); Onum = size -1; Onum = num -1; = Line 44. should be = Ofor(int i = 0; i < things.size(); i++) Ofor(int i = 0; i < things.size()-1; i++) Ofor(int i = 0; i <= things.size(); i++) Ofor(int i = things.size(); i < 0; i++) Line 45. should be Othings.get(i).draw(g); Othings.get(things.size()).draw(g); Othings.draw(g); things.get(things.size(i).draw(g); Othings.get(things.size()-1).draw(g); Othings.get(things.get(1).draw(g);
The following GUI application displays four colored filled circles at the four corners of the square. Every time the user clicks on the panel, one of the circles changes to a random color. First, the top left, then the top right, then the bottom left and then the bottom right and so on. However, there are several errors and/or missing lines. For each of the specified lines below choose the correct line. 6 public class Drawing Panel3 extends JPanel { ArrayList<Circle> things = new ArrayList<Circle>(); int x = 50, y = 50, 1 = 100, radius = 50, num = 0; public Drawing Panel3 () { this. set Background (Color.yellow); this. addMouseListener(); things.add(new Circle(x, y)); //top left things.add(new Circle(x , y));// top right things.add(new Circle(x, y)); // bottom? things.add(new Circle(x, y));//bottom } class Circle { int x = 100; int y = 100; Color c = new Color (1, 1, 1); TO 12 14 16 18 22 24 26 28 30 public Circle (int x, int y) { this.x = x; this.y = y; } public void setColor (Color c) { C = new Color (c); } public void draw(Graphics g) { g. set Color (c); g. filloval(x, y, radius, radius); } } class ClickListener extends MouseAdapter { public void mouseClicked (MouseEvent e) { Color c = new Color ((int) (Math.random() * 256), (int) (Math.random() *256), (int) (Math.random() *256)); things.setColor (c); num++; if (num == 4) num = -1; repaint(); } } @Override protected void paint Component (Graphics g) { super.paint Component(g): g. drawRect(x, y, 1, 1); for (int i = 0; i < things [1]; i++) { things.draw(g); 32 34 36 38 40 42 44 46 } } Line 6. should be
Line 6. should be Othis.addMouseListener(new ClickListener(); Othis.addMouseListener(); Othis.addMouseListener(new MouseListener(ClickListener())); Othis.addMouseListener(this); o this.addMouseListener(new MouseAdapter(new ClickListener())); Othis.addMouseListener(new MouseAdapter()); Line 7. should be Othings.add(new Circle(x-radius/2, y- radius/2)); Othings.add(new Circle((x + 1) - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, (y + 1) - radius/2)); Othings.add(new Circle(x - radius, (y + 1) - radius); Othings.add(new Circle(x, y)); - Line 8. should be Othings.add(new Circle((x + 1) - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, y- radius/2)); Othings.add(new Circlelv - radius/2, (y + 1) - radius/2)); Ā Othings.add(new Circle((x + 1) - radius, y -
Line 8. should be Othings.add(new Circle((x + 1) - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, y- radius/2)); Othings.add(new Circle(x - radius/2, (y + 1) - radius/2)); Othings.add(new Circle((x + 1) - radius, y - radius)); Othings.add(new Circle(x, y)); Line 9. should be Othings.add(new Circle(x - radius/2, (y + 1) - radius/2)); Othings.add(new Circle((x + 1) - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, (y + 1) - radius/2)); things.add(new Circle(x - radius, (y + 1) - radius)); Othings.add(new Circle(x, y));
Line 10. should be Othings.add(new Circle((x + 1) - radius/2, (y + 1) - radius/2)); Othings.add(new Circle((x + 1) - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, y - radius/2)); Othings.add(new Circle(x - radius/2, (y + 1) - radius/2)); things.add(new Circle((x + 1) - radius, (y + 1) - radius)); Othings.add(new Circle(x, y)); Line 33. should be Othings.get(num).setColor(c); Othings.get(num).setColor(new Color); Othings.get(this).setColor(c); things.get(num-1).setColor(c); Othings.get(thing.size()-1).setColor(c); Line 36. should be = = Onum = 0; Onum = 1; Onum = things.size(-1); Onum = size -1; Onum = num-1; = = Л
Line 36. should be = Onum = 0; Onum = 1; Onum = things.size(-1); Onum = size -1; Onum = num -1; = Line 44. should be = Ofor(int i = 0; i < things.size(); i++) Ofor(int i = 0; i < things.size()-1; i++) Ofor(int i = 0; i <= things.size(); i++) Ofor(int i = things.size(); i < 0; i++) Line 45. should be Othings.get(i).draw(g); Othings.get(things.size()).draw(g); Othings.draw(g); things.get(things.size(i).draw(g); Othings.get(things.size()-1).draw(g); Othings.get(things.get(1).draw(g);