Java -> Clearing a text area

Posted on 2007-04-11
Last Modified: 2010-03-31

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 ) ;


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))

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

What am I doing wrong?

Question by:RicardoVGomes
  • 2
LVL 86

Accepted Solution

CEHJ earned 500 total points
ID: 18890977
You need

Clear.addActionListener(new selectionListener());

Author Comment

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

LVL 86

Expert Comment

ID: 18892127

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to see all occupied ports on windows 10 laptop 15 76
Error in @AspectJ Based AOP with Spring 2 18
jboss wildfly 10.1 10 226
Java Restore security prompts not working 10 56
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 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 basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

840 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