Dear All
First of all I wish you a very happy new year.
I have been trying to understand the depreciation matters.
As you can see in the codes below, There are 3 handleEvent methods used as pressbutton action , radio button selection action and dropdown list selection action.
Now I need to replace this method with the " protected void processEvent(AWTEvent e) method ".
How can I implement these three actions of those 3 atomic elements (press button, radio button, drop down list)


Or is there any Swing method that I can use instead? (if so please put a brief explanations on your implementation)


Many thanks in advance
Regards
Juniper2009

public boolean handleEvent(Event evt)
{
    // handleEvent()
  if (evt.id == Event.WINDOW_DESTROY && evt.target == this) Checkers_WindowDestroy(evt.target); //window close action
        else if (evt.id == Event.ACTION_EVENT && evt.target == newGameButton) newGameButton_Action(evt.target); // new game button action
        else if (evt.id == Event.ACTION_EVENT && evt.target == redRadio) redRadio_Action(evt.target);  //red radio button action
        else if (evt.id == Event.ACTION_EVENT && evt.target == blackRadio) blackRadio_Action(evt.target); //black radio button action
        else if (evt.id == Event.ACTION_EVENT && evt.target == toughChoice) toughChoice_Action(evt.target); //drop down list selection action
        else if (evt.id == Event.ACTION_EVENT && evt.target == undoButton) undoButton_Action(evt.target); // undo button action
        else if (evt.id == Event.ACTION_EVENT && evt.target == infoButton) infoButton_Action(evt.target); //info button action
        // End of handleEvent()

        return super.handleEvent(evt);
    }

That is horrible code checking many times for the same condition at least make it that way

public boolean handleEvent(Event evt)
{
    // handleEvent()
  if (evt.id == Event.WINDOW_DESTROY && evt.target == this) Checkers_WindowDestroy(evt.target); //window close action
      return super.handleEvent(evt);
  }


  if (evt.id == Event.ACTION_EVENT) {
     if(evt.target == newGameButton) {
           newGameButton_Action(evt.target); // new game button action
     }
     else if (evt.target == redRadio) {
           redRadio_Action(evt.target);  //red radio button action
     }
     else if (evt.target == blackRadio) {
           blackRadio_Action(evt.target); //black radio button action
     }
     else if (evt.target == toughChoice) {
            toughChoice_Action(evt.target); //drop down list selection action
     }
     else if (evt.target == undoButton) {
         undoButton_Action(evt.target); // undo button action
     }
     else if (evt.target == infoButton) {
          infoButton_Action(evt.target); //info button action
     }

      return super.handleEvent(evt);
    }

By using a WindowListener, an ActionListener, and an ItemListener.

Thannks how would you write codes By using a WindowListener, an ActionListener, and an ItemListener?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.