Results 1 to 4 of 4

Thread: setLayout() and addActionListener().

  1. #1

    Thread Starter
    Lively Member Sebouh's Avatar
    Join Date
    Jan 2005
    Posts
    73

    setLayout() and addActionListener().

    hey guys.
    i have two questions.
    first of all, what does the setLayout do in the applet.
    second, i am having trouble understanding when to put the parameter in the addActionListener "this" or "canvas". since in some examples that i have seen, there is a canvas and a button. To change the color of the text drawn on the canvas when button is pressed, the button's actionlistener is added to the applet. but in other cases like when moveing the mose over the canvas to draw, the actionlistener is added to the canvas.
    i don''t understand why, i mean aren't both actions supposed to be listened byy the canvas?

    thanks for your help.

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: setLayout() and addActionListener().

    Why would the Canvas listen for both actions? When moving the mouse over a Canvas you would want to use a MouseMotionListener. When you want to capture a button event you use a ActionListener.

  3. #3

  4. #4

    Thread Starter
    Lively Member Sebouh's Avatar
    Join Date
    Jan 2005
    Posts
    73

    Re: setLayout() and addActionListener().

    well i got it. in the case where the ActionListener implemented by the canvas, the addActionListener was set to the canvas from the init() method of the applet. In case the applet implemented the Listener then it was written addActionListener(this).

    thanks anyway.

Posting Permissions

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



Click Here to Expand Forum to Full Width