Solved

Java -> Clearing a text area

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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…

863 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

24 Experts available now in Live!

Get 1:1 Help Now