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.
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.
Re: setLayout() and addActionListener().
setLayout(LayoutManager manager) enables you to set the LayoutManager.
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.