help please Java, I will upvote.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

help please Java, I will upvote.

Post by answerhappygod »

help please Java, I will upvote.
Help Please Java I Will Upvote 1
Help Please Java I Will Upvote 1 (171.41 KiB) Viewed 20 times
Help Please Java I Will Upvote 2
Help Please Java I Will Upvote 2 (140.33 KiB) Viewed 20 times
Help Please Java I Will Upvote 3
Help Please Java I Will Upvote 3 (143.69 KiB) Viewed 20 times
Help Please Java I Will Upvote 4
Help Please Java I Will Upvote 4 (124.59 KiB) Viewed 20 times
Help Please Java I Will Upvote 5
Help Please Java I Will Upvote 5 (120.3 KiB) Viewed 20 times
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);
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply