Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I would appreciate some help with this java applet program. I had to write the applet code and the HTML code for it. I

Hi, I would appreciate some help with this java applet program. I had to write the applet code and the HTML code for it. I keep getting an error stating - missing public static void main(String[] args).

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Oval extends JApplet implements ActionListener

{ //variables

private JTextField NumTF;

private JLabel Label; private JButton OKBtn;

private int Num = 0;

//init method

public void init()

{ //container

Container C = getContentPane();

setSize(500, 500);

Label = new JLabel("Enter Number");

Label.setLocation(200, 40);

Label.setSize(100, 30);

NumTF = new JTextField(1);

NumTF.setLocation(300, 40);

NumTF.setSize(100, 30);

OKBtn = new JButton(" OK ");

OKBtn.setLocation(400, 40);

OKBtn.setSize(60, 30);

OKBtn.addActionListener(this);

C.setLayout(null); C.add(Label);

C.add(NumTF); C.add(OKBtn);

}

//paint method

public void paint(Graphics g)

{

super.paint(g);

g.setColor(Color.black);

int Inf = 0, Len =0;

for(int i = 0; i < Num; i++)

{

g.drawOval(20+Inf, 20+Inf, 25+Len, 25+Len);

Inf = Inf + 3;

Len = Len + 5;

}

}

//define method actionperformed takes object of actionevent

public void actionPerformed(ActionEvent e)

{

if (e.getSource() == OKBtn)

{

Num = Integer.parseInt(NumTF.getText());

}

repaint();

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions