import javax.swing.*; import java.awt.event.*; public class Dialog { JFrame frame; JPanel p; public Dialog(){ frame = new JFrame("Show Message Dialog"); p=new JPanel(); JButton button = new JButton("Click Me"); button.addActionListener(new MyAction()); p.add(button); frame.add(p); frame.setSize(400, 400); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public class MyAction implements ActionListener{ public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog(frame,"My DialogBox"); } } public static void main(String[] args) { Dialog db = new Dialog(); } }
FOR COMP SCIENCE & IT
Comments
Post a Comment