Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 19-11-2009
Member
 
Join Date: Jul 2009
Posts: 188
EventListner on Choice Menu

Hi
I need a help with the logic of codes that uses choice menu. I have created a program with 9 buttons in any array. When we press a button we get a corresponding value from an array of integers defined elsewhere. The value which are assigned to a particular button shows up in seperate text filed.
The difficulty which I am facing is
The array of buttons must listen to each of the selection of the choice menu, such that each item selected causes the button to pick from different sets of arrays of values when pressed I will be impressed if any one will help me out. Thanks in advance
Reply With Quote
  #2  
Old 19-11-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: EventListner on Choice Menu

Hi
You mean that when you click on a button you need to get a value from a "set of value" depending on the value of the radio button? If your answer is yes then you do no need any listeners to the radio buttons. Whenever you click the button you will get the value of the radio selected and the with a if statement you can set the value you want to take from. This is the general syntax of this
Code:
   
      // When a button is clicked
      actionPerformed(Action event) {
      // get the value of the choice button currently selected
      // with that choose which "set of values" you will use
      }
If any help is need in future do post back we will solve your problem.
Reply With Quote
  #3  
Old 19-11-2009
Member
 
Join Date: Jul 2009
Posts: 188
Re: EventListner on Choice Menu

Thanks for for posting the syntax. I am posting my problem below step by step, please understand them and then if you know it post with a solution.
These are my choice buttons
Code:
   Choice tc;
      tc=new Choice();
      tc.addItem("A ");
      tc.addItem("B ");
      tc.addItem("C ");
These are my array values
Code:
   static final int[] fare = { 110, 200,100, 160,220,270,280,370,380 };
     static final int[] fareo={110, 110,110, 160, 160, 220,220,220,220,};
      static final int[] fares={160, 320,320, 400, 400, 400,400,400,400};
This is my listener
Code:
 class ZoneListener implements ActionListener {
      public void actionPerformed(ActionEvent e) {
      amount = Integer.parseInt(e.getActionCommand());
I am providing this information see if you can help me out through any solution. Thanks in advance.
Reply With Quote
  #4  
Old 19-11-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: EventListner on Choice Menu

Hi
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 am posting the code below, just go through it.
Code:
 switch (option) {
      case 0:
      selectedFares = fare;
      break;
      case 1:
      selectedFares = fareo;
      break;
      ... etc
      }
This should help you, if not then post back what is the problem. I will try my best to solve your problem.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "EventListner on Choice Menu"
Thread Thread Starter Forum Replies Last Post
Add or remove power user menu items in Windows 8 with Win+X Menu Editor Jhonny.Bravo Customize Desktop 3 17-08-2012 05:43 PM
Windows 7 Start Menu Worthless, appeared as a folder, not a menu Jigya L. Operating Systems 6 15-03-2011 02:39 PM
Display of the Program Menu In Windows 7 As the Cascade Menu dinkster Customize Desktop 4 04-12-2010 11:14 PM
Choice of ram Eyesee Motherboard Processor & RAM 4 22-11-2008 02:16 PM


All times are GMT +5.5. The time now is 04:47 AM.