Solved

Java -> Clearing a text area

Posted on 2007-04-11
3
178 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now