[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

Compile error: else if (e.getActionCommand.equals("Exit"))

Greetings all!  Can anyone tell me why my entry:   else if (e.getActionCommand.equals("Exit")) is causing the following compile error and/or suggest a fix:

C:\progs\TextAreaDemoExercise.java:67: cannot resolve symbol
symbol  : variable getActionCommand
location: class java.awt.event.ActionEvent
        else if (e.getActionCommand.equals("Exit"))
                  ^
Here a code excerpt (below)... I only have this problem when I try and put in the "exit" elements...remove them and it compiles fine.  


        Button get2Button = new Button("Get Memo 2");
        get2Button.addActionListener(this);
        buttonPanel.add(get2Button);

        Button ExitButton = new Button("Exit");                        //Button entry for my exit function....
        ExitButton.addActionListener(this);
        buttonPanel.add(ExitButton);

        add("South", buttonPanel);

        textPanel = new Panel();
        textPanel.setBackground(Color.blue);
        theText = new TextArea(10, 40);
        theText.setBackground(Color.white);
        textPanel.add(theText);
        add("Center", textPanel);
    }

    public void actionPerformed(ActionEvent e)
    {
        if (e.getActionCommand().equals("Save Memo 1"))
        {
            memo1 = theText.getText();
            theText.setText("Memo 1 saved.");
        }
        else if (e.getActionCommand().equals("Save Memo 2"))
        {
            memo2 = theText.getText();
            theText.setText("Memo 2 saved.");
         }
        else if (e.getActionCommand().equals("Clear"))
            theText.setText("");
        else if (e.getActionCommand().equals("Get Memo 1"))
            theText.setText(memo1);
        else if (e.getActionCommand().equals("Get Memo 2"))
            theText.setText(memo2);
        else if (e.getActionCommand.equals("Exit"))           //This is my entry to exit the program
   System.exit(0);                                                  
                                                                           
        else
            System.out.println("Error in memo interface.");

        textPanel.repaint();//Shows changes in textPanel
    }
0
rockyisin
Asked:
rockyisin
1 Solution
 
rockyisinAuthor Commented:
Answered my own question!  Sorry for waisting brain power!  I forgot the ().
0
 
CEHJCommented:
Post a 0 point q to http://www.experts-exchange.com/Community_Support/ and they'll give you your points back
0
 
DarthModCommented:
Submitted to PAQ with points refunded (125)

DarthMod
Community Support Moderator
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now