What is wrong in this code of java
import javax.swing.*;
public class shape
{
public static void main(String[] args)
{
JFrame f=new JFrame("hi");
f.setSize(300,200);
f.setDefaultCloseOperation(JFrame.EX…
f.setVisible(true);
draw ob1=new draw();
f.add(ob1);
}
}
/*************************************…
import java.awt.*;
//import java.awt.color.*;
public class draw extends JFrame
{
public void paint(Graphics g)
{
g.drawOval(10, 10, 50, 50);
g.fillOval(5, 5, 10, 10);
}
}
Re: What is wrong in this code of java
Hi kank635, welcome to the forums!
If you find a problem with the code it might be a good idea if *you* said what it is. Specifically, does the code compile? If not and you can't understand the compiler's messages post them and someone is sure to explain what they mean.
Or does the code compile but you find it does not do what you expect or intend when you run it? In that case describe what the program *does* do (including any runtime errors) as well as what you expected or intended it would do.
Also, please format code. The idea is you put [code] at the start of the code and [/code] at the end. That way the code will be nicely formatted and readable when it appears here.