Skip to content
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ java/awt/datatransfer/ConstructFlavoredObjectTest/ConstructFlavoredObjectTest.ja
java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.java 8202882 linux-all
java/awt/Focus/NonFocusableBlockedOwnerTest/NonFocusableBlockedOwnerTest.java 7124275 macosx-all
java/awt/Focus/TranserFocusToWindow/TranserFocusToWindow.java 6848810 macosx-all,linux-all
java/awt/Component/NativeInLightShow/NativeInLightShow.java 8202932 linux-all
java/awt/FileDialog/ModalFocus/FileDialogModalFocusTest.java 8194751 linux-all
java/awt/image/VolatileImage/BitmaskVolatileImage.java 8133102 linux-all
java/awt/SplashScreen/MultiResolutionSplash/unix/UnixMultiResolutionSplashTest.java 8203004 linux-all
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2021, 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 All @@ -26,68 +26,68 @@
@key headful
@bug 4140484
@summary Heavyweight components inside invisible lightweight containers still show
@author Your Name: art@sparc.spb.su
@run main NativeInLightShow
*/

import java.awt.*;
import java.awt.event.*;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Container;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.InputEvent;


// The test verifies that the mixing code correctly handles COMPONENT_SHOWN events
// while the top-level container is invisible.

public class NativeInLightShow
{
public class NativeInLightShow {
//Declare things used in the test, like buttons and labels here
static boolean buttonPressed = false;
public static void main(String args[]) throws Exception {
Frame f = new Frame("Test");

Robot robot = null;
robot = new Robot();
robot.setAutoDelay(50);

Container c = new Container();
c.setLayout(new BorderLayout());
Button b = new Button("I'm should be visible!");
b.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
System.out.println("Test PASSED");
buttonPressed = true;
}
});
c.add(b);
static volatile boolean buttonPressed = false;

public static void main(String[] args) throws Exception {
Frame frame = new Frame("Test");

f.add(c);
Robot robot = new Robot();

f.pack();
Container container = new Container();
container.setLayout(new BorderLayout());
Button button = new Button("I'm should be visible!");
button.addActionListener(e -> {
System.out.println("Test PASSED");
buttonPressed = true;
});

c.setVisible(false);
c.setVisible(true);
container.add(button);
frame.add(container);
frame.pack();

container.setVisible(false);
container.setVisible(true);

// Wait for a while for COMPONENT_SHOW event to be dispatched
robot.waitForIdle();

f.setVisible(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);

robot.waitForIdle();
robot.delay(1000);

Point buttonLocation = b.getLocationOnScreen();
Point buttonLocation = button.getLocationOnScreen();

robot.mouseMove(buttonLocation.x + 5, buttonLocation.y + 5);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

// Wait for a while for ACTION event to be dispatched
robot.waitForIdle();
robot.delay(100);
robot.delay(500);

frame.dispose();
if (!buttonPressed) {
System.out.println("Test FAILED");
throw new RuntimeException("Button was not pressed");
}
}

}