Solved

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

Posted on 2003-11-22
4
279 Views
Last Modified: 2010-04-16
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
Comment
Question by:rockyisin
4 Comments
 

Author Comment

by:rockyisin
ID: 9803964
Answered my own question!  Sorry for waisting brain power!  I forgot the ().
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9804016
Post a 0 point q to http://www.experts-exchange.com/Community_Support/ and they'll give you your points back
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 11688316
Submitted to PAQ with points refunded (125)

DarthMod
Community Support Moderator
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question