Perdorimi i dritareve dialoguese te konfirmimit

Nje kuti dritareje konfirmimi shfaq opsionet yes, no cancel perveç mesazhit qe afishohet.

Metoda showConfirmDialog() e klases JoptionPane permban disa argumenta qe jane:

  1. parent component qe mund te jete null,
  2. stringun qe do afishohet,
  3. titullin e dritares,
  4. nje numer te plote qe tregon cilet opsione te butonave do te shfaqen,

 

YES_NO_CANCEL_OPTION,

YES_NO_OPTION, 

OK_CANCEL_OPTION

 

  1. nje numer te plote qe tregon llojin e dritares dialoguese:

 

ERROR_MESSAGE,

INFORMATION_MESSAGE,

WARNING_MESSAGE,

QUESTION_MESSAGE, ose

PLAIN_MESSAGE.

Shembull:


     import javax.swing.JOptionPane;

public class ConfirmDialog

{

public static void main(String[] args)

{

int zgjedhje;

boolean po;

zgjedhje = JOptionPane.showConfirmDialog(null,

"A ju pelqen gjuha e programimit JAVA?","Dritare



konfirmimi",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);

po = (zgjedhje == JOptionPane.YES_OPTION);

JOptionPane.showMessageDialog(null,

"Pergjigja juaj ishte " + po);

}

}

 


     import javax.swing.JOptionPane;

public class ConfirmDialog1

{

public static void main(String[] args)

{

int zgjedhje;

zgjedhje = JOptionPane.showConfirmDialog(null,

"A ju pelqen gjuha e programimit JAVA?","Dritare



konfirmimi",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);

if(zgjedhje == JOptionPane.YES_OPTION)

JOptionPane.showMessageDialog(null,"Pergjigja juaj ishte po");

else

JOptionPane.showMessageDialog(null,"Pergjigja juaj ishte jo");

}

}