Computer Science Canada Buttons/Counter Question |
Author: | Crim009 [ Sun Oct 24, 2004 9:59 am ] | ||
Post subject: | Buttons/Counter Question | ||
Hey guys, i got a mini assignment from school and i need some help on it. I've created 3 frames so far but i don't really understand the concept of the counters with the buttons. like how to click on "Question 1" and make it pop up and make the menu "false". I don't understand how to add counters to the buttons. So if someone could help me get started with just one of the frames, greatly appreciated I will use ur model to understand the buttons better. Comments in the codes are appreciated Thanks. *Using RTP
|
Author: | rizzix [ Sun Oct 24, 2004 10:07 am ] |
Post subject: | |
u'd need to add in an event listener |
Author: | Crim009 [ Sun Oct 24, 2004 5:05 pm ] |
Post subject: | |
Ok after adding action listener, i still don't understand how to make the buttons work, anyone with more descriptive help? I need to get this thanks ![]() |
Author: | rizzix [ Sun Oct 24, 2004 7:07 pm ] |
Post subject: | |
update ur code will ya.. i'll show u where ur going wrong. |
Author: | Crim009 [ Sun Oct 24, 2004 7:20 pm ] |
Post subject: | |
I added 'implements ActionListener' but I don't know how to make the Question 1 frame pop up when you click on it and make the menu invisible. sorry for asking dumb questions but I don't understand how to use counters to do this, my teacher gave me an example but I don't understand it, if you could help me get started, that would be great. thanks pls add comments if u can |
Author: | rizzix [ Sun Oct 24, 2004 7:45 pm ] |
Post subject: | |
hmm think about it logically just implementing Actionlistener is not going to get what u want done automatically. firstly delete that "implements...." part that u added in there next u create an inner class that extends the ActionListener interface.. u can learn more on this by reading this tutorial: Abstract Class, Interface and Nested Class now read the "whole" tutorial carefully (at least 3 times over) u'll be aware of the subtle but important ideas i've tried to convey. and u will also be able to use and implement interfaces correctly. just make sure u dont skip over anything. this only a hint. and the first step u need to do ofcourse.. now. after reading it. u should try and use it in your code up there. |
Author: | Crim009 [ Sun Oct 24, 2004 8:27 pm ] |
Post subject: | |
Hey, why do you have to use a more complicated method? Our teacher gave us an example using getsource, so could you explain how i could use that on my program instead? I'm too newb to handle that innerclass thingy >_< ![]() ![]() |
Author: | rizzix [ Mon Oct 25, 2004 2:21 pm ] | ||||
Post subject: | |||||
well an inner class is just an ordinary class declared within the scope of another class.. thats all it is.. but you could have just as well have created an ordinary class that implements the ActionListener interface. and it would work nevertheless.. although, it makes a lot of sense to use an inner class. here's an example of an inner class :
of course just creating a class that would handle the event is not good enough.. u need to create objects of this class and link them with the buttons you created. you do this something like this:
|
Author: | Crim009 [ Mon Oct 25, 2004 5:17 pm ] |
Post subject: | |
hey thanks for the help rizzix, I will try it out. If I have more problems I will post....seems like ur the only one answrering my questions lol |