Example #1
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == b1) {
     Deletion form2 = new Deletion();
     f1.dispose();
   }
   if (e.getSource() == b2) {
     TestPat form = new TestPat();
     f1.dispose();
   }
 }
  public static void main(String[] args) {
    for (int i = 0; i < 100; i++) {
      Frame f = new Frame();
      f.pack();
      f.dispose();
    }

    Vector garbage = new Vector();
    while (true) {
      try {
        garbage.add(new byte[1000]);
      } catch (OutOfMemoryError e) {
        break;
      }
    }
    garbage = null;

    Vector<WeakReference<Window>> windowList =
        (Vector<WeakReference<Window>>) AppContext.getAppContext().get(Window.class);

    if (windowList != null && !windowList.isEmpty()) {
      throw new RuntimeException("Test FAILED: Window list is not empty: " + windowList.size());
    }

    System.out.println("Test PASSED");
  }
Example #3
0
  private static void init() {
    // *** Create instructions for the user here ***
    String[] instructions = {
      "This is an AUTOMATIC test, simply wait until it is done.",
      "The result (passed or failed) will be shown in the",
      "message window below."
    };
    Sysout.createDialog();
    Sysout.printInstructions(instructions);

    Frame frame = new Frame("test for 6418028");
    frame.setLayout(new FlowLayout());
    Button btn1 = new Button("Button1");
    frame.add(btn1);
    TestButton btn2 = new TestButton("Button2");
    frame.add(btn2);
    frame.pack();
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent we) {
            we.getWindow().dispose();
          }
        });
    frame.setVisible(true);

    Util.waitForIdle(null);

    btn2.instrumentPeer();
    btn2.requestFocusInWindow();
    btn2.restorePeer();
    frame.dispose();
    RequestOnCompWithNullParent1.pass();
  } // End  init()
 @Override
 protected void tearDown() throws Exception {
   super.tearDown();
   if ((frame != null) && frame.isDisplayable()) {
     frame.dispose();
   }
 }
Example #5
0
 public void dispose() {
   f.dispose();
   f = null;
   dummy.dispose();
   dummy = null;
   if (modal_d != null) {
     modal_d.dispose();
     modal_d = null;
   }
 }
 private void closeAll() {
   if (dialog != null) {
     dialog.dispose();
   }
   if (parentDialog != null) {
     parentDialog.dispose();
   }
   if (parentFrame != null) {
     parentFrame.dispose();
   }
 }
Example #7
0
 protected final java.io.OutputStream getOutputStream() throws IOException {
   if (isClosed()) {
     if (TRAKTOR_USED && traktor != null && !traktorConnectionDown) {
       traktor.dispose();
       traktor = null;
     }
     throw new IOException("connection closed");
   }
   OutputStream os = getOutputStream0();
   if (os == null) throw new IOException("connection closed");
   return os;
 }
  /**
   * Method declaration
   *
   * @param ev
   */
  public void windowClosing(WindowEvent ev) {

    try {
      cConn.close();
    } catch (Exception e) {
    }

    fMain.dispose();

    if (bMustExit) {
      System.exit(0);
    }
  }
 public static void main(final String[] args) {
   for (int i = 0; i < 10; ++i) {
     final Frame frame = new Frame();
     frame.setSize(300, 300);
     frame.setLocationRelativeTo(null);
     ButtonRepaint button = new ButtonRepaint();
     frame.add(button);
     frame.setVisible(true);
     sleep();
     button.test();
     frame.dispose();
   }
 }
Example #10
0
  public final void doExitApplication() {

    try {
      IGV.getInstance().saveStateForExit();

      Frame mainFrame = IGV.getMainFrame();
      // Hide and close the application
      mainFrame.setVisible(false);
      mainFrame.dispose();

    } finally {
      System.exit(0);
    }
  }
Example #11
0
  void doTest() throws Exception {

    ArrayList<Component> components = new ArrayList();
    components.add(button);
    components.add(buttonLW);
    components.add(textField);
    components.add(textArea);
    components.add(list);
    components.add(listLW);

    int keys[];
    String OS = System.getProperty("os.name").toLowerCase();
    System.out.println(OS);
    if (OS.contains("os x") || OS.contains("sunos")) {
      keys = new int[] {KeyEvent.VK_SHIFT, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_META};
    } else {
      keys = new int[] {KeyEvent.VK_SHIFT, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT};
    }

    for (Component c : components) {

      System.out.print(c.getClass().getName() + ": ");

      Point origin = c.getLocationOnScreen();
      int xc = origin.x + c.getWidth() / 2;
      int yc = origin.y + c.getHeight() / 2;
      Point center = new Point(xc, yc);

      robot.delay(robotDelay);
      robot.glide(origin, center);
      robot.click();
      robot.delay(robotDelay);

      for (int k = 0; k < keys.length; ++k) {

        keyPressReceived = false;

        keyCode = keys[k];

        robot.type(keyCode);

        robot.delay(robotDelay);

        if (!keyPressReceived) {
          synchronized (lock) {
            try {
              lock.wait(waitDelay);
            } catch (InterruptedException e) {
            }
          }
        }

        assertTrue(keyPressReceived, "key press event was not received");
      }

      System.out.println("passed");
    }

    robot.waitForIdle();
    frame.dispose();
  }
  public void testDrawLinesAWT() throws Exception {

    Frame dummy = new Frame();
    Window[] windows = new Window[3];
    Waypoint[] painted = new Waypoint[windows.length];

    for (int i = 0; i < 3; i++) {

      painted[i] =
          new Waypoint(); // this gets cleared in the paint method of the TestWindow, so we know
      // that at least on paint() call has been made

      // create the test windows
      switch (i) {
        case 0:
          windows[i] = new TestWindow(dummy, painted[i], RenderingHints.VALUE_ANTIALIAS_ON);
          break;
        case 1:
          windows[i] = new TestWindow(dummy, painted[i], RenderingHints.VALUE_ANTIALIAS_OFF);
          break;
        case 2:
          windows[i] = new TestWindow(dummy, painted[i], RenderingHints.VALUE_ANTIALIAS_DEFAULT);
          break;
        default:
          throw new Exception("Should not get here!");
      }

      windows[i].setBounds(50 + (i * (kWidth + 5)), 50, kWidth, KHeight);
      // VisibilityValidator checkpoint = new VisibilityValidator(windows[i]); // Re-add this when
      // VisiblityValidator handes windows (currently only handles frames)
      windows[i].setVisible(true);

      // checkpoint.requireVisible();
      // assertTrue( "Could not confirm test window was visible", checkpoint.isValid() );

      Thread.sleep(kPaintTimeOut);

      painted[i].requireClear();
      assertTrue(
          "paint() not called on test window after " + kPaintTimeOut + "ms", painted[i].isClear());

      // dumpRedsFromImage(w);	// <-- turn this on for debugging info

      for (int ii = 0; ii < kProbePoints.length; ii++) {

        // Collect the colors of points just off the test line
        Point screen_offset = windows[i].getLocationOnScreen();
        int x = screen_offset.x + kProbePoints[ii].x;
        int y = screen_offset.y + kProbePoints[ii].y;
        Color fProbeColor = kRobot.getPixelColor(x, y);

        assertNotNull(fProbeColor);
        switch (i) {
            // RenderingHints.VALUE_ANTIALIAS_ON
          case 0:
            assertTrue(
                "Point just off line with ANTIALIAS_ON should not be white",
                Color.white.equals(fProbeColor) == false);
            break;

            // RenderingHints.VALUE_ANTIALIAS_OFF
          case 1:
            assertEquals(
                "Point just off line with ANTIALIAS_OFF should be white", Color.white, fProbeColor);
            break;

            // RenderingHints.VALUE_ANTIALIAS_DEFAULT
          case 2:
            assertEquals(
                "For non-Aqua, point just off line with VALUE_ANTIALIAS_DEFAULT should be white",
                Color.white,
                fProbeColor);
            break;
          default:
            throw new Exception("Should not get here!");
        }
      }
    }

    // make sure the window is up and drawn once
    Thread.sleep(100); // <-- do asserts here

    for (int i = 0; i < 3; i++) {
      windows[i].dispose();
    }

    dummy.dispose();
  }
Example #13
0
 public void windowClosing(WindowEvent arg0) {
   f.dispose();
 }