|
-
I need text area help
OK I have an applet with three panels, North Center and South. North and
Center each contain a TextArea and South contains a label and two buttons.
I want to reverse the text in North and set it in center when one of the
buttons get clicked.Can anyone Look at the code and tell me what I am missing:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Encryption extends Applet implements ActionListener
{
TextArea firstTextArea;
TextArea secondTextArea;
Button firstButton;
Button secondButton;
public void init()
{
firstTextArea = new TextArea();
secondTextArea = new TextArea();
Panel p1=new Panel();
p1.setLayout(new FlowLayout());
p1.add(firstTextArea);
Panel p2=new Panel();
p2.setLayout(new FlowLayout());
p2.add(secondTextArea);
secondTextArea.setEditable(false);
Panel p3=new Panel();
p3.add(new Label("Welcome to Encryption",Label.LEFT));
setLayout(new BorderLayout());
add("North",p1);
add("Center",p2);
add("South",p3);
firstButton = new Button("CLEAR");
secondButton = new Button("ENCRYPT");
p3.add(firstButton);
firstButton.addActionListener(this);
p3.add(secondButton);
secondButton.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String actionCommand = e.getActionCommand();
if (actionCommand.equals("Encrypt"))
{
StringBuffer reverseText = new StringBuffer();
String cypherText = new String();
cypherText = (firstTextArea.getText().trim());
reverseText.append(cypherText);
reverseText.reverse();
//Store results of reversal back in original String
cypherText = reverseText.toString();
secondTextArea.setText(cypherText);
}
else if (actionCommand.equals("Clear"))
{
firstTextArea.setText("");
secondTextArea.setText("");
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks