import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; import java.awt.*; public class j extends JApplet implements ActionListener, ChangeListener { private JLabel lab; private JComboBox cb; private JCheckBox chb; private JRadioButton rb; private JTextArea ta; private JButton but; public void actionPerformed(ActionEvent a) { if (a.getSource() == but) lab.setText("You touched the button, the combobox " + "says '" + cb.getSelectedItem() + "'"); else if (a.getSource() == rb) chb.setSelected(!chb.isSelected()); } public void stateChanged(ChangeEvent a) { lab.setText("'" + ta.getText() + "' and " + ((JSlider)a.getSource()).getValue()); } public void init() { Container pane = getContentPane(); JSlider sli = new JSlider(); String[] data = {"a", "b", "c"}; lab = new JLabel("push the button or move with the slider"); but = new JButton("button"); ta = new JTextArea("text area"); cb = new JComboBox(data); chb = new JCheckBox("This is checkbox"); rb = new JRadioButton("This is radio"); rb.addActionListener(this); sli.addChangeListener(this); but.addActionListener(this); pane.setLayout(new GridLayout(12,1)); pane.add(chb); pane.add(rb); pane.add(new JLabel("this is label")); pane.add(new JLabel("slider here:")); pane.add(sli); pane.add(ta); pane.add(but); pane.add(cb); pane.add(lab); } }