Get premium membership and access questions with answers, video lessons as well as revision papers.

Create a program in java and name it DrawCircle.When the single button is clicked, it should draw a circle of pixel diameter.

      

Create a program in java and name it DrawCircle.When the single button is clicked, it should draw a circle of pixel diameter.

  

Answers


Davis
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);
}
}

Githiari answered the question on January 26, 2018 at 12:14


Next: Define the term compiler as used in programming
Previous: Write a program which draws a large ‘T’ shape on the screen.

View More Computer Studies Questions and Answers | Return to Questions Index


Learn High School English on YouTube

Related Questions