Clicking on a JPanel to draw shapes

后端 未结 3 1105
没有蜡笔的小新
没有蜡笔的小新 2021-01-22 09:54

I have a JFrame containing 3 JPanels; Options, menu, canvas. In options there are a number of JButtons representing shapes. The aim is to click on the JButton of a shape e.g. re

3条回答
  •  生来不讨喜
    2021-01-22 10:14

    I had to overwrite the canvas class' paint method; call super.paint in the canvas class and repaint each shape individually

    public void paint(Graphics g){
                super.paint(g);
                for(int i=0;i

提交回复
热议问题