Use of the joptionpane dialog box
Import java. AWT. event .*;
Import javax. Swing .*;
Class myframe extends jframe
{
Jbutton B1;
Public static void main (string ARGs [])
{
Myframe F = new myframe ();
}
Public myframe ()
{
/* Super () method is used to invoke the base class constructor */
Super ("window title ");
B1 = new jbutton ("Click here ");
Getcontentpane (). Add ("center", B1 );
// Register the listener for the button
Buttonlistener blisten = new buttonlistener ();
B1.addactionlistener (blisten );
Setsize (200,200 );
Setvisible (true );
}
// The Listener class
Class buttonlistener implements actionlistener
{
Public void actionreceivmed (actionevent EVT)
{
Jbutton source = (jbutton) EVT. getsource ();
Source. settext ("button clicked ");
Joptionpane. showmessagedialog (myframe. This, "button
Clicked "," information ", joptionpane. information_message );
}
}
}