/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
@test
@bug 4452384
@summary Tests that non-focusable windows doesn't generate any focus events when accessed.
@author Denis.Mikhalkin: area=awt.focus
@run main NoEventsTest
*/
static boolean automatic = true;
robot.waitForIdle();
}
listener = new GlobalListener();
try{
} catch(Exception e) {}
// Create several pairs - focusable Frame with focusable component(button) and non-focusable:
// window, resizable frame, non-resizable frame, dialog, non-resiable dialog
main_frame.pack();
main_frame.setVisible(true);
public void windowClosing(WindowEvent e) {
}
});
//windows[1] = new TestWindow(2, 1, true, main_frame);
//windows[4] = new Test(3, 0, true, true);
if (!automatic) {
int windowInd;
}
}
}
// Run the test
// 1. Click on all controls, check for no focus events for non-focusable, right focus events for focusable
// 2. Perform some action with control, check if it works
if (automatic) {
int windowInd;
pause(1000);
// Verify that click on non-focusable window causes no focus lost on active window
pause(500);
// Verify that toFront, toBack doesn't cause non-focusable window to become active
jumpingFrame.setVisible(true);
pause(1000);
pause(500);
pause(500);
pause(500);
pause(500);
// Verify that iconifiyng/deiconfiying and
// window to become active
// Deiconification currently doesn't work!
// toTest.setExtendedState(Frame.ICONIFIED);
// pause(500);
// toTest.setExtendedState(Frame.NORMAL);
pause(500);
pause(500);
}
}
}
pause(1000);
throw new RuntimeException("Test Failed. See error stream output for details");
}
}
}
return;
}
pause(100);
}
}
}
return;
}
pause(100);
}
}
}
if (NoEventsTest.automatic) {
}
Label l = new Label(getClass().getSuperclass().getName() + ", " + (focusable?"focusable":"non-focusable") +
add("North", l);
if (!focusable) {
setFocusableWindowState(false);
}
if (!resizable) {
setResizable(false);
}
// setVisible(true);
}
}
super(owner);
if (NoEventsTest.automatic) {
}
Label l = new Label(getClass().getSuperclass().getName() + ", " + (focusable?"focusable":"non-focusable") +
", " + (false?"resizable":"non-resizable"));
add("North", l);
setBounds(NoEventsTest.DEF_LEFT + NoEventsTest.DEF_WIDTH*col, NoEventsTest.DEF_TOP + NoEventsTest.DEF_HEIGHT*row, NoEventsTest.DEF_WIDTH, NoEventsTest.DEF_HEIGHT);
if (!focusable) {
setFocusableWindowState(false);
}
// setVisible(true);
}
}
super(owner);
if (NoEventsTest.automatic) {
}
Label l = new Label(getClass().getSuperclass().getName() + ", " + (focusable?"focusable":"non-focusable") +
add("North", l);
setBounds(NoEventsTest.DEF_LEFT + NoEventsTest.DEF_WIDTH*col, NoEventsTest.DEF_TOP + NoEventsTest.DEF_HEIGHT*row, NoEventsTest.DEF_WIDTH, NoEventsTest.DEF_HEIGHT);
if (!focusable) {
setFocusableWindowState(false);
}
if (!resizable) {
setResizable(false);
}
// setVisible(true);
}
}
return;
}
}
}
}
}
}
}
}
setLayout(new FlowLayout());
Button b;
// b.addMouseListener(new MouseAdapter() {
// public void mousePressed(MouseEvent e) {
// System.err.println(e);
// }
// });
TextField t;
list.setMultipleMode(true);
public Dimension getPreferredSize() {
}
};
public Dimension getPreferredSize() {
}
};
}
}
public boolean report() {
} else {
return true;
}
}
return false;
}
public GlobalListener() {
}
}
}
}
if (!(e instanceof WindowEvent || e instanceof FocusEvent)) {
}
// Skip WINDOW_OPENED
}
switch (e.getID()) {
case WindowEvent.WINDOW_OPENED:
case WindowEvent.WINDOW_CLOSING:
case WindowEvent.WINDOW_CLOSED:
case WindowEvent.WINDOW_ICONIFIED:
return;
case WindowEvent.WINDOW_LOST_FOCUS: {
reportError(e, "frame lost focus because of non-focusable window");
}
break;
}
}
// Check that Window owner is focusable
if (!parent.getFocusableWindowState()) {
}
if (!comp.isFocusable()) {
reportError(e, "focus event for non-focusable component");
}
// if (e instanceof WindowEvent || e instanceof FocusEvent) {
// // System.err.println(e);
// }
}
}