All pastes #518405 Raw Edit

KIKKE

public text v1 · immutable
#518405 ·published 2007-05-29 09:21 UTC
rendered paste body
import 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
        }
    }
}