rendered paste bodyimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Komponentit extends JApplet implements ActionListener
{
protected JButton b;
protected JTextField tf;
protected JLabel l;
protected JRadioButton rb;
public void init() {
b = new JButton("Nappula");
getContentPane().add(b, "North");
b.addActionListener(this);
l = new JLabel("Label");
getContentPane().add(l, "South");
tf = new JTextField(20);
getContentPane().add(tf, "West");
tf.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
if(ae.getSource() == b) {
// nappulan b vaikutuksen alaiset lauseet
}
else if(ae.getSource() == tf) {
// tekstikentän tf käynnistämät toiminnot
}
else {
//kytkimen rb jutut
}
}
}