コード例 #1
0
 public void testContextIsJDialogWhenJDialogIsShown() {
   JDialog dialog = new JDialog();
   JButton comp = new JButton();
   dialog.getContentPane().add(comp);
   windowContext.setActiveWindow(comp);
   assertSame(dialog, windowContext.activeWindow());
 }
コード例 #2
0
 public void testContextIsJAppletWhenJAppletIsShown() {
   JApplet applet = new JApplet();
   JButton button = new JButton();
   applet.getContentPane().add(button);
   windowContext.setActiveWindow(applet);
   assertSame(applet, windowContext.activeWindow());
 }
コード例 #3
0
 public void testContextIsJFrameWhenJFrameIsShown() {
   JFrame frame = new JFrame();
   JButton comp = new JButton();
   frame.getContentPane().add(comp);
   windowContext.setActiveWindow(comp);
   assertSame(frame, windowContext.activeWindow());
 }
コード例 #4
0
 public void testWaitForDialogWithActiveWindowAsTargetDialog() throws InterruptedException {
   JFrame frame = new JFrame();
   JDialog testDialog = new JDialog(frame, "testDialog");
   setFocusManager(testDialog);
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, testDialog));
   windowContext.waitForDialogOpening("testDialog", 10);
   assertSame(testDialog, windowContext.activeWindow());
   testDialog.dispose();
   frame.dispose();
 }
コード例 #5
0
 public void testContextIsJAppletWhenACompentInItHasFocus() {
   Frame frame = new Frame();
   JApplet applet = new JApplet();
   JButton button = new JButton();
   frame.add(applet);
   applet.getContentPane().add(button);
   setFocusManager(button);
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, button));
   assertSame(applet, windowContext.activeWindow());
 }
コード例 #6
0
 public void testContextIsJFrameWhenInternalFrameIsShown() {
   JFrame frame = new JFrame();
   JInternalFrame internalFrame = new JInternalFrame();
   JTextField textField = new JTextField();
   setFocusManager(textField);
   internalFrame.getContentPane().add(textField);
   frame.getContentPane().add(internalFrame);
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, textField));
   assertSame(frame, windowContext.activeWindow());
   assertSame(frame, windowContext.activeTopLevelWindow());
 }
コード例 #7
0
 public void testWaitsForDialogToClose() {
   final JDialog dialog = new JDialog((Frame) null, "title");
   setFocusManager(dialog);
   windowContext.setActiveWindow(dialog);
   final JFrame frame = new JFrame("newFocusOwner");
   new Thread(
           new Runnable() {
             public void run() {
               windowContext.setActiveWindow(frame);
             }
           })
       .start();
   windowContext.waitForDialogClosing("title", 1000);
   assertSame(frame, windowContext.activeWindow());
 }
コード例 #8
0
 public void testWaitForActiveDialogWhenDialogIsNotReady() throws InterruptedException {
   final JDialog testDialog = new JDialog(new JFrame(), "testDialog");
   setFocusManager(testDialog);
   new Thread(
           new Runnable() {
             public void run() {
               windowContext.propertyChange(
                   new PropertyChangeEvent(this, "focusOwner", null, testDialog));
             }
           })
       .start();
   windowContext.waitForDialogOpening("testDialog", 10);
   assertEquals(testDialog, windowContext.activeWindow());
   testDialog.dispose();
 }
コード例 #9
0
 public void testSetsActiveWindowToNullIfThereIsNoRootPaneContainer() {
   JButton button = new JButton();
   KeyboardFocusManager.setCurrentKeyboardFocusManager(new TestKeyboardFocusManager(button));
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, button));
   assertNull(windowContext.activeWindow());
 }
コード例 #10
0
 public void testSetsActiveWindowWhenFocusChanges() {
   JFrame frame = new JFrame();
   KeyboardFocusManager.setCurrentKeyboardFocusManager(new TestKeyboardFocusManager(frame));
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, frame));
   assertSame(frame, windowContext.activeWindow());
 }