JFrame_JPanel2.htm
  •  g.fillOval( 50, 110, 120, 60 );
    // "touch up" the mouth into a smile
    g.setColor( Color.YELLOW );
    g.fillOval( 50, 120, 120, 40 );
  •  g.drawRoundRect(50, 50, 150, 250,50, 150);
  • g.setColor( Color.RED);
    //topleft 50, topheight 25, wide 50,
    //height object 10,round 60 and 30, ,
    g.fillRoundRect(50, 25,50,10,60 ,20);
    g.fillRoundRect(125,25,50,10,30 ,60);
  •  
Code : JFrame_JPanel2.txt

Scripts:

package javatemplate1;

import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class JavaTemplate1 {
public static void main(String[] args) {
// TODO code application logic here
//System.out.println("main block executing bbb ");
JPanel content = new JPanel();
JFrame window = new JFrame("GUI Test");
ExternalClass1 ex1 = new ExternalClass1();
content.setLayout(new BorderLayout());
content.add( ex1, BorderLayout.CENTER);
window.setContentPane(content);
window.setSize(300,300);
window.setLocation(500,100);// left top
window.setVisible(true);
}
}
/// external class

package javatemplate1;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;

public class ExternalClass1 extends JPanel{
public void paintComponent(Graphics g) {
super.paintComponent( g );
// draw the face
g.setColor( Color.YELLOW );
g.fillOval( 10, 10, 200, 200 );
//
g.drawArc(5, 10, 20, 30, 50,100);
// draw the eyes
g.setColor( Color.BLACK );
g.fillOval( 55, 65, 30, 30 );
g.fillOval( 135, 65, 30, 30 );
// draw the mouth
g.fillOval( 50, 110, 120, 60 );
// "touch up" the mouth into a smile
g.setColor( Color.YELLOW );
g.fillOval( 50, 120, 120, 40 );
//Ceate uneven ey6borws
g.drawRoundRect(50, 50, 150, 250,50, 150);
g.setColor( Color.RED);
//topleft 50, topheight 25, wide 50,
//height object 10,round 60 and 30, ,
g.fillRoundRect(50, 25,50,10,60 ,20);
g.fillRoundRect(125,25,50,10,30 ,60);

} // end method paintComponent
}

 

Runtime views: