Trusted by millions of Kenyans
Study resources on Kenyaplex

Get ready-made curriculum aligned revision materials

Exam papers, notes, holiday assignments and topical questions – all aligned to the Kenyan curriculum.

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

Answer Attachments

Exams With Marking Schemes

Related Questions