//wap to demo for Paint Mode in Swing Programming
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class mypanel extends JPanel
{
public void paintComponent(Graphics g)
{
g.setColor(Color.red);
g.fillOval(100,50,50,50);
g.setXORMode(Color.pink);
g.setColor(Color.green);
g.fillOval(100,80,60,60);
}
}
class myframe3 extends JFrame
{
Container c;
myframe3()
{
mypanel p=new mypanel();
c=getContentPane();
c.add(p);
}
public static void main(String args[])
{
myframe3 f=new myframe3();
f.setTitle("paint");
f.setSize(600,600);
f.setVisible(true);
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
}
}
No comments:
Post a Comment