1. Design an archery-style target with concentric circles. Then add different colours. 2. Open the existing DrawExample program with an editor. Save it under the name DrawCircle.java. Change the three...


1. Design an archery-style target with concentric circles. Then add different colours.


2. Open the existing DrawExample program with an editor. Save it under the name DrawCircle.java. Change the three occurrences of DrawExample into DrawCircle, ensuring that the capitalization is correct. Finally, call the drawOval method with appropriate parameters, in the actionPerformed method. Here is the complete program:


import java.awt.*;


Import java.awt.event.*;


import javax.swing.*;


public class DrawCircle extends JFrame


implements ActionListener {


private JButton button;


private JPanel panel;


public static void main(String[] args) {


DrawCircle frame = new DrawCircle();


frame.setSize(400, 300);


frame.createGUI();


frame.setVisible(true);


}


private void createGUI() {


setDefaultCloseOperation(EXIT_ON_CLOSE);


Container window = getContentPane();


window.setLayout(new FlowLayout() );


panel = new JPanel();


panel.setPreferredSize(new Dimension(300, 200));


panel.setBackground(Color.white);


window.add(panel);


button = new JButton("Press me");


window.add(button);


button.addActionListener(this);


}


public void actionPerformed(ActionEvent event) {


Graphics paper = panel.getGraphics();


paper.drawOval(0, 0, 100, 100);


}


}




May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here