Re: EventListener for sequence of events Programming Software Development by taineechan Now that I have one eventlistener, how do I know which button is pressed? Is there something like an isClicked method? EventListener for sequence of events Programming Software Development by taineechan Hi I'm coding a game of towers in java. I'm having trouble moving a stack from one button to another. I have eventlisteners for buttons A and B. If Button A is clicked and then button B is clicked, the value at button A must be added to the value at button B. <the values are text on the buttons> How can I achieve this? Re: EventListener for sequence of events Programming Software Development by thekashyap Well you've gotta have some common place to store the values of these buttons.. So may be have a class (say my_container) to contain these values. Catch is both the button's handler classes must have access to same object of this my_container class. You can do this is with [URL="http://en.wikipedia.org/wiki/Singleton_pattern"]Singleton … Re: EventListener for sequence of events Programming Software Development by masijade Well, if the instances of the Buttons themselves are known to the ActionListener (i.e. they are instance variables that the ActionListener has access to) you can simply use getText() to get the displayed value on the button. Re: EventListener for sequence of events Programming Software Development by thekashyap [quote=masijade;331692]Well, if the instances of the Buttons themselves are known to the ActionListener (i.e. they are instance variables that the ActionListener has access to) you can simply use getText() to get the displayed value on the button.[/quote] Is it not that ActionListners for both buttons would be different objects? If so you'll run … Re: EventListener for sequence of events Programming Software Development by masijade [QUOTE=thekashyap;331740]Is it not that ActionListners for both buttons would be different objects? If so you'll run into same problem. (both ActionListner objects have to know both Button objects). Instead on click of A, update the value in "common place" and on click of B pickup the value from "common place" and do the needful… Re: EventListener for sequence of events Programming Software Development by taineechan I've put all my buttons into a 2D array and they use one listener. I'm gonna try the if statement and previous variable thing. I'll only try Singleton if that doesn't work coz I personally find design patterns a little scary. Thanks so much for the help:) Re: EventListener for sequence of events Programming Software Development by thekashyap What's the type of listner you're using? (Class name) If you're using/registering a single listner object for both buttons' click event, you can do what masijade said. [quote=taineechan;331804] I'll only try Singleton if that doesn't work coz I personally find design patterns a little scary.[/quote] They are not scary. And you've GOT TO try … Re: EventListener for sequence of events Programming Software Development by taineechan My class implements ActionListener and then I have: [code] public void actionPerformed(ActionEvent event) JButton button = (JButton)event.getSource(); [/code] I have tried Singleton. In C++ though.. Re: EventListener for sequence of events Programming Software Development by thekashyap Seems like button.isSelected() will do teh job for you.. Re: EventListener for sequence of events Programming Software Development by taineechan Thanks so much for all the help.. It's working now:) EventListener on Choice Menu Programming Software Development by bobinson Could anyone pls help out with the logic of codes that uses Choice menu. The choice buttons were created with its items(3 in this case) I have another sets of 9 buttons in an array Each button,when pressed gets a corresponding value from an array of integers defined elsewhere The obtained value assigned to a particular button shows up… Re: EventListener on Choice Menu Programming Software Development by javaAddict If I understood correctly whenever you click a button you need to get a value from a "set of values" depending on the value of the radio button? If yes then you don't need any listeners to the radio buttons. Whenever a button is clicked, you can get the value of the radio selected and then with if statements select the set you want to … Re: EventListener on Choice Menu Programming Software Development by bobinson Thanks a lot Javaddict,I do really appreciate your attempt to help.Here I'm including sections of my problem perhaps that would make things a a lot more clear My choice button were created thus [CODE=java] Choice travelChoice; travelChoice=new Choice(); travelChoice.addItem("A "); travelChoice.addItem("B "); travelChoice.addItem… Re: EventListener on Choice Menu Programming Software Development by Ezzaral Just have an int[] array variable like "selectedFares[]" that points to the correct fare array. Your stateChanged method just needs to set it when they choose one, i.e.[CODE]switch (option) { case 0: selectedFares = fare; break; case 1: selectedFares = fareo; break; ... etc }[/CODE]If your fares were in a 2D … Re: EventListener on Choice Menu Programming Software Development by bobinson Thanks very much Ezzaral,you must be a savior indeed!However,I have being trying my hands on the idea you supplied but have not being able to get it working.I'm still on it. Re: EventListener on Choice Menu Programming Software Development by Ezzaral Let's say your fares were in an array [iCODE]fares[3][][/iCODE]. Then your option group index directly corresponds to a fare schedule[code]selectedFare = fares[optionIndex];[/code]No need for a switch. The rest of your code just references [iCODE]selectedFare[i][/iCODE]. Using a class defined in a different file Programming Software Development by BobFX …gt; ^args) { Console::WriteLine(L"Hello World"); EventListener *listener = new EventListener(); return 0; }[/code] That compiles in Visual Studio without…gt; ^args) { Console::WriteLine(L"Hello World"); EventListener *listener = new EventListener(); return 0; }[/code] in the first main file, the… Re: Using a class defined in a different file Programming Software Development by pac-man …]#include "stdafx.h" using namespace System; class EventListener { long mRef; public: EventListener() { mRef = 0; } };[/code] [/QUOTE] Rename the following … "stdafx.h" using namespace System; #include "EventListener.h" // here int main(array<System::String ^>… Re: Using a class defined in a different file Programming Software Development by BobFX [QUOTE=pac-man;1084412] Rename the following as main.cpp and add the following line #include "EventListener.h" as follows[/QUOTE] Duh, I was seing a class as an external routine (I'm used to C, not yet to C++) rather than as a definition. Thanks. ImportError: no module named main? Programming Software Development by jcafaro10 … I made up). In java I have this: [CODE] for(EventListener l:myMap.get(i.getType())) { Class c = l.getClass… constructor Programming Software Development by kartik.patel.3348 …incoming info //set up the listener EventListener listener = new EventListener(); leftArrowButton.addActionListener(listener); rightArrowButton.addActionListener(…forward or back through photo list*/ private class EventListener implements ActionListener{ public void actionPerformed (ActionEvent e){… I get hard time when debugging this bug however this is the C++ life Programming Software Development by NicAx64 …. Then I just turn off some includes like #include "EventListener.h" and #include "Torken.h" and tries… to compile. well I want to say that inside the EventListener.h if __TORKEN_H__ is not definied then it include the… Can't open any programs Hardware and Software Information Security by netzone …\Support.com\bin\tgkill.exe /cleaneahtioga /start O4 - HKLM\..\Run: [EVENTLISTENER] C:\Program Files\Nikon\NkView\EvLstnr.exe O4 - HKLM\..\Run… Re: Can't open any programs Hardware and Software Information Security by netzone …] C:\Program Files\Iomega\DriveIcons\deskup.exe O4 - HKLM\..\Run: [EVENTLISTENER] C:\Program Files\Nikon\NkView\EvLstnr.exe O4 - HKLM\..\Run… Re: Can't open any programs Hardware and Software Information Security by netzone …] C:\Program Files\Iomega\DriveIcons\deskup.exe O4 - HKLM\..\Run: [EVENTLISTENER] C:\Program Files\Nikon\NkView\EvLstnr.exe O4 - HKLM\..\Run… parent/child Programming Software Development by ceyesuma ….WindowConstants; import java.awt.Event; import org.w3c.dom.events.EventListener; import org.w3c.dom.events.MouseEvent; import java.lang.String… Login Problem Programming Software Development by tactfulsaint …; this.password=password; } } import java.util.* ; public interface LoginListener extends EventListener { public void validateLogin(LoginEvent user); } import java.awt.* ; import java… need help.. Programming Software Development by caierhui ….event.*; import javax.swing.*; import java.awt.*; import java.util.EventListener; public class Assign_1 extends JFrame { private JLabel quizOneL,quizTwoL,quizThreeL… What listener to use for my Program Programming Software Development by arcticman452 ….*; import java.util.*; public class TravelerGasolineCalculator extends JFrame implements ActionListener, EventListener { //declare variables int totalMiles, mpg; double oilChange = 30.00, fuelCost…