Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: please help me with windowlistener

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy please help me with windowlistener

    hi all ,
    I am new to java , i wrote a simple applet , it did not work , i tried windowlistener , it gave an error when i tried to add the listener , whats wrong . But when i add mouse or key listener i dont get this error

    my code :
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class maximizerepaint extends Applet implements WindowListener

    {
    public void init(){addWindowListener(this);}
    public void start(){}
    public void windowActivated(WindowEvent we){}
    public void windowClosed(WindowEvent we){}
    public void windowClosing(WindowEvent we){}
    public void windowDeactivated(WindowEvent we){}
    public void windowDeiconified(WindowEvent we){}
    public void windowIconified(WindowEvent we){}
    public void windowOpened(WindowEvent we){}
    public void paint(Graphics g){update(g);}
    public void update(Graphics g){g.drawRect(0,0,10,10);}
    }

    error:cannot find symbol addWindowListener(maximizerepaint)


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: please help me with windowlistener

    Hello and welcome to the javaprogrammingforums.com!

    Your problem is that you're trying to add a WindowListener to an Applet, a class that has no addWindowListener(...) method, and so the compiler is justifiably complaining. I suggest that you not even use Applets but rather use a more modern GUI library, the Swing library. There are great tutorials on how to use Swing which you can find here: Using Swing Components.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: please help me with windowlistener

    Thanks a lot !!! That gives me a start

    --- Update ---

    i searched the forum for books on java swing , found one , can you please suggest me some books or is the online source good enough for a beginner like me , i apologize if i am posting the wrong question for the forum

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: please help me with windowlistener

    I've already given you the best source that I know of in a link in my answer above.

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: please help me with windowlistener

    thanks a lot