Results 1 to 5 of 5
  1. #1
    koushikG is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default GUI based java program where size of the frame increases

    i need a GUI based java program where size of the frame increases whenever mouse is clicked over the frame.Plz help me

  2. #2
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    304
    Rep Power
    6

    Default

    Is there a Question attached? Have you attempted to make one?

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Agree. A little demonstration of effort and an actual question will go a long way to motivating many to help.

  4. #4
    koushikG is offline Member
    Join Date
    Nov 2010
    Posts
    3
    Rep Power
    0

    Default

    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

  5. #5
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    304
    Rep Power
    6

Similar Threads

  1. Trying to calculate cost based on size
    By space4rent00 in forum New To Java
    Replies: 4
    Last Post: 03-22-2010, 07:13 AM
  2. Replies: 2
    Last Post: 02-08-2010, 12:03 AM
  3. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 04:37 PM
  4. Prob. with screen resolution and Frame size??
    By SANDY_INDIA in forum AWT / Swing
    Replies: 1
    Last Post: 08-16-2008, 12:51 PM
  5. [SOLVED] How to set the frame size?
    By impact in forum New To Java
    Replies: 7
    Last Post: 05-02-2008, 11:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •