![[java vowel blanker.png|400]]
The following code produces a vowel blanker. It contains a JTextArea wrapped in a JScrollPane and a JTextfield. Text is entered in the JTextField and then copied to the JTextArea where the vowels are converted to \*s
```java
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
*
* @author ajb
*/public class GUITextArea extends JFrame implements ActionListener{
JTextArea textArea = new JTextArea(25,10);
JScrollPane output = new JScrollPane(textArea);
JTextField input = new JTextField();
GUITextArea() {
setSize(640,480);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container vert = Box.createVerticalBox();
vert.add(output);
vert.add(input);
add(vert);
input.addActionListener(this);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
Font font = new Font("Times New Roman", Font.ITALIC, 14);
textArea.setFont(font);
textArea.setForeground(Color.BLUE);
setVisible(true);
}
public static void main(String[] args) {
new GUITextArea();
}
@Override
public void actionPerformed(ActionEvent ae) {
String text = convert(input.getText());
textArea.append(text + "\n");
input.setText("");
}
public String convert(String s) {
return s.replaceAll("[AEIOUaeiou]", "*");
}
}
```
# JTextArea Exercise
1. Implement the vowel blanker code. Check that you understand what it does
2. Modify the font of the JTextArea so that it is a sans serif font, no effects, size 16
3. Modify the colour of the JTextArea so it's red
4. Add JButton called clear to the vowel blanker. Set it to clear the JTextArea of the vowel blanker when pressed (setText(""))
## Extension
1. Read about rot13 encryption here: <https://en.wikipedia.org/wiki/ROT13>. Modify your vowel blanker so that text entered in the JTextField appears in the JTextArea under rot13 encryption