i need a GUI based java program where size of the frame increases whenever mouse is clicked over the frame.Plz help me
Printable View
i need a GUI based java program where size of the frame increases whenever mouse is clicked over the frame.Plz help me
Is there a Question attached? Have you attempted to make one?
Agree. A little demonstration of effort and an actual question will go a long way to motivating many to help.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
class MyFrame1 extends Frame
{
MyFrame1()
{
setTitle("this is the Frame....");
setBackground(Color.GREEN);
setSize(200,200);
setVisible(true);
setFont(new Font("Dialog",Font.BOLD,10));
MyMouseAdapter adapter=new MyMouseAdapter(this);
addMouseListener(adapter);
//addWindowListener(new MyWindowAdapter(this));
}
public void paint(Graphics g)
{
g.drawString("Click HERE",30,60);
}
}
class MouseClick
{
public static void main(String args[])
{
MyFrame1 mf=new MyFrame1();
}
}
class MyMouseAdapter extends MouseAdapter
{
MyFrame1 mf1;
int x=200;int y=200,a=10;
MyMouseAdapter(MyFrame1 mf1)
{
this.mf1=mf1;
}
public void mousePressed(MouseEvent me)
{
x+=20;
y+=20;a+=1;
mf1.setSize(x,y);
if(x==500)
{
x=100;
a=10;
}
if(y==500)
{
y=100;
a=10;
}
Font f=new Font("Dialog",Font.BOLD,a);
mf1.setFont(f);
}
}
//I CAN'T ABLE TO EXIT SYSTEM IN THIS PROGRAM.PLESE HELP