• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JOptionPane.showConfirmDialog -- i need help!

 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i am displaying a confirm dialog box like



it displays a dialog box, with "YES" option selected. What i want is to make the default selection of "NO" option. How can i?
 
dinesh Venkatesan
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mport javax.swing.*;

public class Tester {
public static void main(String[] args) {
JButton yesButton = new JButton("Yes");
JButton noButton = new JButton("No");
Object buttonArray[] = {yesButton,noButton};
JOptionPane.showOptionDialog(null,"Hai","Hai",JOptionPane.YES_NO_OPTION,JOptionPane.PLAIN_MESSAGE,new ImageIcon("test.jpg"),buttonArray,buttonArray[1]);
}
}

Hope this helps for you!
dinesh.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Muhammad Ali", we don't have too many rules around here but we do have a Naming Policy. Please adjust your display name accordingly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic