A Simple Message Box In Java
Monday, 10 February 2014Posted by
Amrishwa
0 Comments
To do this job Two java components are needed
- jButton1
- jLabel1
Now we have to put this code on jButton1ActionPerformed
As written below
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){int a=JOptionPane.showConfirmDialog(mainPanel,"Have a Good Day","Please Press Ok or Cancel",JOptionPane.OK_CANCEL_OPTION);if(a==0){jLabel1.setText("You HAve Pressed Ok");}else if(a==2){jLabel1.setText("You Have Pressed Cancel");}else if(a==-1){jLabel1.setText("Dont Play a Joke with me");}else{jLabel1.setText("Wow");}}
Subscribe to:
Post Comments (Atom)