I have created a window containing only one button(park1). All I need is a new dialog(with
"OK" and "Cancel" buttons to open when I click on park1.
Thanks in advance.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MyWin extends JFrame implements ActionListener
{
JButton park1;
MyWin()
{
setSize(450, 500);
setVisible(true);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents();
}
void initComponents()
{
park1 = new JButton("Add");
setLayout(null);
add(park1);
park1.setBounds(130, 350, 100, 40);
park1.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
try
{
Object temp = e.getSource();
if(temp.equals(park1))
{
//code for opening a new window
}
}
catch(Exception ex)
{
}
}
public static void main(String args[])
{
MyWin mw1 = new MyWin();
}
}