import java.awt.*; import java.awt.event.*; import java.net.URL; import javax.swing.*; public class SButton extends SJanela { JButton b; class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent ae) { System.out.println(b.getActionCommand() +": " + ae); } } public SButton() { super("Janela com botao"); try { b = new JButton("OK", new ImageIcon(new URL("file:annotn.gif"))); } catch (Exception e) { b = new JButton("OK"); } b.addActionListener(new ButtonHandler()); getContentPane().add(b); } public static void main(String[] args) { SButton jb = new SButton(); jb.setVisible(true); } }