Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class Temp extends JFrame{
- private JPanel panel1;
- private JButton button1;
- private Temp() {
- button1.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- setVisible(false);
- JOptionPane.showMessageDialog(null, "Hello World");
- }
- });
- }
- public static void main(String[] args) {
- JFrame tempWindow = new JFrame("TempWindow");
- tempWindow.setContentPane(new Temp().panel1);
- tempWindow.setLocationRelativeTo(null); // this line set the window in the center of the screen
- tempWindow.setDefaultCloseOperation(tempWindow.EXIT_ON_CLOSE);
- tempWindow.pack();
- tempWindow.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement