Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4.  
  5. public class Temp extends JFrame{
  6. private JPanel panel1;
  7. private JButton button1;
  8.  
  9. private Temp() {
  10. button1.addActionListener(new ActionListener() {
  11. @Override
  12. public void actionPerformed(ActionEvent e) {
  13. setVisible(false);
  14. JOptionPane.showMessageDialog(null, "Hello World");
  15. }
  16. });
  17. }
  18.  
  19.  
  20. public static void main(String[] args) {
  21. JFrame tempWindow = new JFrame("TempWindow");
  22. tempWindow.setContentPane(new Temp().panel1);
  23. tempWindow.setLocationRelativeTo(null); // this line set the window in the center of the screen
  24. tempWindow.setDefaultCloseOperation(tempWindow.EXIT_ON_CLOSE);
  25. tempWindow.pack();
  26. tempWindow.setVisible(true);
  27.  
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement