Solved

Java -> Clearing a text area

Posted on 2007-04-11
3
180 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
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

823 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