Skip to content

8295804: javax/swing/JFileChooser/JFileChooserSetLocationTest.java failed with "setLocation() is not working properly" #1633

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

Closed
Closed
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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,6 +29,7 @@
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -209,7 +210,11 @@ private static void hitKeys(int... keys) {
}

public static void createUI() {
frame = new JFrame();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

int xPos = (int) screenSize.getWidth() / 2;
int yPos = (int) screenSize.getHeight() / 2;
frame = new JFrame("FileChooser set location test");
panel = new JPanel();
btn = new JButton(SHOW_DIALOG_OUTSIDE_THE_PANEL);
btn1 = new JButton(SHOW_DIALOG_OVER_THE_PANEL);
Expand Down Expand Up @@ -238,6 +243,7 @@ public static void createUI() {
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setLocation(xPos, yPos - 200);
frame.setVisible(true);
}

Expand Down Expand Up @@ -280,7 +286,6 @@ protected JDialog createDialog(Component parent)
System.out.println(
"createDialog and set location to (" + x + ", " + y + ")");
dialog.setLocation(x, y);

return dialog;
}

Expand All @@ -289,5 +294,4 @@ public Point getDialogLocation() {
}

}

}