JButton endButton = new JButton("Click to end program"); endButton.addActionListener(new endProgramActionListener()); someJFrame.add(endButton);