import java.awt.*;
    import java.awt.event.*; 
    import javax.swing.*; 
    import javax.accessibility.*; 
   
    public class HelloSwing implements ActionListener { 
     private JFrame jFrame; 
     private JLabel jLabel; 
     private JPanel jPanel; 
     private JButton jButton; 
     private AccessibleContext accContext; 
  
     private String labelPrefix = "Number of button clicks: "; 
     private int numClicks = 0; 
  
    public void go() { 
   jFrame = new JFrame("HelloSwing"); 
   jLabel = new JLabel(labelPrefix + "0"); 
  
   jButton = new JButton("I am a Swing button!"); 
  
   jButton.setMnemonic('i'); 
  
   jButton.addActionListener(this); 
   accContext = jButton.getAccessibleContext(); 
    accContext.setAccessibleDescription("Pressing this button increments " + 
   "the number of button clicks"); 
   
   
    jPanel = new JPanel(); 
   jPanel.setBorder(BorderFactory.createEmptyBorder(12.30,30,10,30)); 
  
  
   jPanel.add(jButton); 
   jPanel.add(jLabel); 
   jFrame.setContentPane(jPanel); 
  
  
   WindowListener wl = new WindowAdapter() { 
   public void windowClosing(WindowEvent e) { 
   System.exit(0); 
   } 
   }; 
   jFrame.addWindowListener(wl); 
  
   jFrame.pack(); 
   jFrame.setVisible(true); 
   } 
  
   // Button handling. 
    public void actionPerformed(ActionEvent e) { 
    numClicks++; 
    jLabel.setText(labelPrefix + numClicks); 
    } 
   
   public static void main(String[] args) { 
   
    HelloSwing helloSwing = new HelloSwing(); 
   helloSwing.go(); 
   } 
  }