コード例 #1
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();
 }
コード例 #2
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());
 }
コード例 #3
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());
 }
コード例 #4
0
  public void testWaitsTillProgressBarCompletes() {
    final JFrame frame = new JFrame();

    final JProgressBar progressBar1 = new JProgressBar();
    final JProgressBar progressBar2 = new JProgressBar(0, 10);
    createProgressBarsInFrame(frame, progressBar1, progressBar2);
    setFocusManager(frame);

    windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, progressBar2));

    long before = System.currentTimeMillis();

    Thread thread1 = spawnFirstThreadToInactivateFirstProgressBar(progressBar1);
    Thread thread2 = spawnSecondThreadToInactivateSecondProgressBar(progressBar2);

    windowContext.waitForProgressBar();
    long after = System.currentTimeMillis();

    assertTrue((after - before) > 500);
    ThreadUtil.sleep(100);
    assertFalse(thread1.isAlive());
    assertFalse(thread2.isAlive());
    frame.dispose();
  }
コード例 #5
0
 public void testSetsActiveWindowToNullIfThereIsNoRootPaneContainer() {
   JButton button = new JButton();
   KeyboardFocusManager.setCurrentKeyboardFocusManager(new TestKeyboardFocusManager(button));
   windowContext.propertyChange(new PropertyChangeEvent(this, "focusOwner", null, button));
   assertNull(windowContext.activeWindow());
 }
コード例 #6
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());
 }