How to paint an arrayList of shapes Java

前端 未结 2 1888
盖世英雄少女心
盖世英雄少女心 2020-12-22 12:41

I am tasked with how to paint an arrayList of shapes in java.

I feel i have most of it right, there are two methods i am confused about however

the method in

2条回答
  •  旧时难觅i
    2020-12-22 13:23

    super.paintComponent(g) invokes the paintComponent method from the superclass of JPanel (the JComponent class) to erase whatever is currently drawn on the panel. This is useful for animation, but not for setting color.

    I guess you'll have to set the color of the shapes in your Arraylist shapes when you will create them, nonetheless it could be helpfull to see the Shape class. Maybe you could create a function changeColor(Color ColorToBeSet) in this shape class and loop through the shapes ArrayList to call it at the end of your ShapeListener

提交回复
热议问题