Skip to content

8361067: Test ExtraButtonDrag.java requires frame.dispose in finally block #26043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.InvocationTargetException;


public class ExtraButtonDrag extends Frame {
static String tk = Toolkit.getDefaultToolkit().getClass().getName();
Expand All @@ -43,13 +45,14 @@ public class ExtraButtonDrag extends Frame {
static int [] buttonsClicked;
volatile static boolean dragged = false;
volatile static boolean moved = false;
private static Frame frame;

public ExtraButtonDrag(){
super("ExtraButtonDrag");
}

public static void main(String []s){
Frame frame = new ExtraButtonDrag();
public static void main(String []s) throws InvocationTargetException, InterruptedException, AWTException{
frame = new ExtraButtonDrag();

MouseAdapter ma = new MouseAdapter() {
public void mouseDragged(MouseEvent e) {
Expand Down Expand Up @@ -120,8 +123,9 @@ public void mouseReleased(MouseEvent e) {
}
}
}
} catch (Exception e){
throw new RuntimeException("", e);
}
finally {
EventQueue.invokeAndWait(ExtraButtonDrag::disposeFrame);
}
}

Expand Down Expand Up @@ -151,4 +155,10 @@ public static void dragMouse(int button, int x0, int y0, int x1, int y1){
robot.mouseRelease(button);
}

public static void disposeFrame() {
if (frame != null) {
frame.dispose();
frame = null;
}
}
}