import
java.awt.event.*;
import
java.awt.*;
import
javax.swing.*;
class
text11
extends
JFrame
implements
ActionListener {
static
JFrame f;
static
JButton b, b1, b2, b3;
static
JLabel l, l1;
static
JTextArea jt;
text11()
{
}
public
static
void
main(String[] args)
{
f =
new
JFrame("textfield");
l =
new
JLabel("nothing entered");
l1 =
new
JLabel("
0
lines");
b =
new
JButton("submit");
b1 =
new
JButton("plain");
b2 =
new
JButton("italic");
b3 =
new
JButton("bold");
text11 te =
new
text11();
b.addActionListener(te);
b1.addActionListener(te);
b2.addActionListener(te);
b3.addActionListener(te);
jt =
new
JTextArea("please write something ",
10
,
10
);
JPanel p =
new
JPanel();
p.add(jt);
p.add(b);
p.add(b1);
p.add(b2);
p.add(b3);
p.add(l);
p.add(l1);
f.add(p);
f.setSize(
300
,
300
);
f.show();
}
public
void
actionPerformed(ActionEvent e)
{
String s = e.getActionCommand();
if
(s.equals("submit")) {
l.setText(jt.getText() + ", ");
l1.setText(jt.getLineCount() + " lines");
}
else
if
(s.equals("bold")) {
Font f =
new
Font("Serif", Font.BOLD,
15
);
jt.setFont(f);
}
else
if
(s.equals("italic")) {
Font f =
new
Font("Serif", Font.ITALIC,
15
);
jt.setFont(f);
}
else
if
(s.equals("plain")) {
Font f =
new
Font("Serif", Font.PLAIN,
15
);
jt.setFont(f);
}
}
}