0

I'm developing a program in java for admin orders in a restaurant. I have a screen like this. Frame for admin orders.

I want to select any button from left and any button from right and clic in button "Agregar" later. I'm thinking to do a method with a lot of conditions if and else if, for example.

if(buttonCombo1.isSelected() and buttonNumber1.isSelected()){
//Doing something
}else if(buttonCombo1.isSelected() and buttonNumber2.isSelected()){
//Doing something
}

I would have to do a lot of conditions, and I have no idea do otherwise. If you can help me to find another way for do It, I would be grateful.

Note: I apologize for my bad english. I'm learning yet. Thanks so much.

Allanh
  • 465
  • 1
  • 7
  • 19

1 Answers1

0

I don't remember if you can group simple buttons. But you can define a click function in each button to change the value of button in a Bollean Array (with lenght equals amount of button.)

In this case, you will have acess a boolean value directly for a index.

  • I don't think well. I need to know what button is pressed and take actions, but there are a lot of buttons and each button has a action different. If button one is pressed, action will be different and I'm searching of way to don't do a lot of conditions. – Allanh Jul 12 '16 at 21:37
  • Well, in this case, you can create states to definy after each click the next event or group of state to define the next event. See: http://stackoverflow.com/questions/5923767/simple-state-machine-example-in-c – João Santos Jul 12 '16 at 21:44