
Hi Friend,
Try the following code:
import java.awt.*;
import javax.swing.*;
public class Smiley extends JPanel{
public void paint(Graphics g){
Font f = new Font("Helvetica", Font.BOLD,20);
g.setFont(f);
g.drawString("Keep Smiling!!!", 50, 30);
g.setColor(Color.yellow);
g.fillOval(60, 60, 200, 200);
g.setColor(Color.black);
g.fillOval(120, 100, 20, 70);
g.setColor(Color.black);
g.fillOval(180, 100, 20, 70);
g.drawArc(100, 120, 115, 115, 0, -180);
}
public static void main(String args[]){
JFrame frame = new JFrame();
frame.getContentPane().add(new Smiley());
frame.setSize(450, 350);
frame.show();
}
}
Thanks

Hi Friend,
Try the following code:
import java.awt.*;
import javax.swing.*;
public class Smiley extends JPanel{
public void paint(Graphics g){
Font f = new Font("Helvetica", Font.BOLD,20);
g.setFont(f);
g.drawString("Keep Smiling!!!", 50, 30);
g.setColor(Color.yellow);
g.fillOval(60, 60, 200, 200);
g.setColor(Color.black);
g.fillOval(120, 100, 20, 70);
g.setColor(Color.black);
g.fillOval(180, 100, 20, 70);
g.drawArc(100, 120, 115, 115, 0, -180);
}
public static void main(String args[]){
JFrame frame = new JFrame();
frame.getContentPane().add(new Smiley());
frame.setSize(450, 350);
frame.show();
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.