1 19 20 package org.netbeans.core.windows.services; 21 22 import java.awt.Dialog ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import javax.swing.JButton ; 26 import junit.framework.TestCase; 27 import org.openide.DialogDescriptor; 28 import org.openide.DialogDisplayer; 29 30 34 public class DialogDisplayer50960Test extends TestCase { 35 private boolean performed = false; 36 37 public DialogDisplayer50960Test (String testName) { 38 super (testName); 39 } 40 41 protected void setUp() throws Exception { 42 performed = false; 43 } 44 45 46 public void testRedundantActionPerformed () { 48 JButton b1 = new JButton ("Do"); 49 JButton b2 = new JButton ("Don't"); 50 ActionListener listener = new ActionListener () { 51 public void actionPerformed (ActionEvent event) { 52 assertFalse ("actionPerformed() only once.", performed); 53 performed = true; 54 } 55 }; 56 DialogDescriptor dd = new DialogDescriptor ( 57 "...", 58 "My Dialog", 59 true, 60 new JButton [] {b1, b2}, 61 b2, 62 DialogDescriptor.DEFAULT_ALIGN, 63 null, 64 null 65 ); 66 dd.setButtonListener (listener); 67 Dialog dlg = DialogDisplayer.getDefault ().createDialog (dd); 68 b1.doClick (); 69 assertTrue ("Button b1 invoked.", performed); 70 } 71 72 73 } 74 | Popular Tags |