Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyDialog extends JDialog {
- public static int APPLY_OPTION= 1;
- protected int buttonpressed;
- protected JButton okButton;
- public MyDialog(Frame f) {
- super(f);
- okButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- buttonpressed= APPLY_OPTION;
- }
- } );
- public int getButtonPressed() {
- return buttonpressed;
- }
- }
- public class testMyDialog {
- @Test
- public void testGetButtonPressed() {
- MyDialog fc= new MyDialog(null);
- fc.okButton.???????? //how do I activate the ActionListener?
- assertEquals(MyDialog.APPLY_OPTION, fc.getButtonPressed());
- }
- }
- JButton button = (JButton)PrivateAccessor.get(MyDialog , "okButton");
- Thread t = new Thread(new Runnable() {
- public void run() {
- // What ever you want
- };
- });
- t.start();
- button.doClick();
- t.join();
Add Comment
Please, Sign In to add comment