Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Java -> Clearing a text area

Posted on 2007-04-11
3
Medium Priority
?
193 Views
Last Modified: 2010-03-31
Hello,

private JButton Clear;
private static JTextArea  sqlQuery;

Clear                      = new JButton("Clear Query");
sqlQuery             = new JTextArea();
jsp2                         = new JScrollPane ( sqlQuery, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS ) ;

add(Clear);
add(jsp2);

Clear.setBounds                  (860, 650, 120, 20);
jsp.setBounds                      (20, 35, 250, 600);

class selectionListener implements ActionListener{
            public void actionPerformed (ActionEvent e) {

///other events

else if (e.getSource().equals(Clear))
                {
                        sqlQuery.setText("");
                }


I also tried using null istead of "" inside the paranthesis, but that didnt work.

What am I doing wrong?

Thanks
0
Comment
Question by:RicardoVGomes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 18890977
You need

Clear.addActionListener(new selectionListener());
0
 

Author Comment

by:RicardoVGomes
ID: 18891043
Can't believe I forgot that...

Thanks!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18892127
:-)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

609 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