|
-
Aug 22nd, 2005, 04:05 AM
#1
Thread Starter
Lively Member
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.
-
Aug 24th, 2005, 01:02 AM
#2
Dazed Member
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.
-
Aug 24th, 2005, 01:13 AM
#3
Dazed Member
Re: setLayout() and addActionListener().
setLayout(LayoutManager manager) enables you to set the LayoutManager.
-
Aug 24th, 2005, 03:33 AM
#4
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|