Skip to content

Commit 9724132

Browse files
author
Andrew Lu
committedFeb 22, 2024
8306752: Open source several container and component AWT tests
Backport-of: 88d9ebf8e80eeead3e4a1494ba537530c16b75e1
1 parent c905214 commit 9724132

File tree

4 files changed

+664
-0
lines changed

4 files changed

+664
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,376 @@
1+
/*
2+
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
@test
26+
@bug 4240721
27+
@summary Test Component.getListeners API added in 1.3
28+
@key headful
29+
@run main GetListenersTest
30+
*/
31+
32+
import java.awt.Button;
33+
import java.awt.Canvas;
34+
import java.awt.Checkbox;
35+
import java.awt.CheckboxMenuItem;
36+
import java.awt.Choice;
37+
import java.awt.Component;
38+
import java.awt.EventQueue;
39+
import java.awt.FlowLayout;
40+
import java.awt.Frame;
41+
import java.awt.Label;
42+
import java.awt.Menu;
43+
import java.awt.MenuBar;
44+
import java.awt.MenuItem;
45+
import java.awt.Panel;
46+
import java.awt.Scrollbar;
47+
import java.awt.TextArea;
48+
import java.awt.TextField;
49+
import java.awt.event.ActionEvent;
50+
import java.awt.event.ActionListener;
51+
import java.awt.event.AdjustmentEvent;
52+
import java.awt.event.AdjustmentListener;
53+
import java.awt.event.ComponentAdapter;
54+
import java.awt.event.ComponentListener;
55+
import java.awt.event.ContainerAdapter;
56+
import java.awt.event.ContainerListener;
57+
import java.awt.event.FocusAdapter;
58+
import java.awt.event.FocusListener;
59+
import java.awt.event.HierarchyBoundsAdapter;
60+
import java.awt.event.HierarchyBoundsListener;
61+
import java.awt.event.HierarchyEvent;
62+
import java.awt.event.HierarchyListener;
63+
import java.awt.event.InputMethodEvent;
64+
import java.awt.event.InputMethodListener;
65+
import java.awt.event.ItemEvent;
66+
import java.awt.event.ItemListener;
67+
import java.awt.event.KeyAdapter;
68+
import java.awt.event.KeyListener;
69+
import java.awt.event.MouseAdapter;
70+
import java.awt.event.MouseListener;
71+
import java.awt.event.MouseMotionAdapter;
72+
import java.awt.event.MouseMotionListener;
73+
import java.awt.event.MouseWheelEvent;
74+
import java.awt.event.MouseWheelListener;
75+
import java.awt.event.TextEvent;
76+
import java.awt.event.TextListener;
77+
import java.awt.event.WindowAdapter;
78+
import java.awt.event.WindowEvent;
79+
import java.awt.event.WindowFocusListener;
80+
import java.awt.event.WindowListener;
81+
import java.awt.event.WindowStateListener;
82+
import java.beans.BeanInfo;
83+
import java.beans.EventSetDescriptor;
84+
import java.beans.Introspector;
85+
import java.beans.PropertyChangeEvent;
86+
import java.beans.PropertyChangeListener;
87+
import java.lang.reflect.Method;
88+
import java.util.EventListener;
89+
90+
public class GetListenersTest {
91+
92+
public static void main(String args[]) throws Exception {
93+
EventQueue.invokeAndWait(()-> {
94+
// Create frame with a bunch of components
95+
// and test that each component returns
96+
// the right type of listeners from Component.getListeners
97+
GLTFrame gltFrame = new GLTFrame();
98+
try {
99+
gltFrame.initAndShowGui();
100+
gltFrame.test();
101+
} catch (Exception e) {
102+
throw new RuntimeException("Test failed", e);
103+
} finally {
104+
gltFrame.dispose();
105+
}
106+
});
107+
}
108+
109+
/*
110+
* Checks an object has a listener for every support listener type
111+
*/
112+
static void checkForListenersOfEveryType(Object object) throws Exception {
113+
Class type = object.getClass();
114+
115+
BeanInfo info = Introspector.getBeanInfo(type);
116+
EventSetDescriptor esets[] = info.getEventSetDescriptors();
117+
118+
// ensure there are listeners for every type
119+
for (int nset = 0; nset < esets.length; nset++) {
120+
Class listenerType = esets[nset].getListenerType();
121+
EventListener listener[] = getListeners(object, listenerType);
122+
// Skip PropertyChangeListener for now
123+
if (listener.length == 0 && validListenerToTest(listenerType)) {
124+
throw new RuntimeException("getListeners didn't return type "
125+
+ listenerType);
126+
}
127+
}
128+
129+
System.out.println("************");
130+
System.out.println("PASSED: getListeners on "
131+
+ object + " has all the right listeners.");
132+
System.out.println("************");
133+
}
134+
135+
/*
136+
* Calls getListeners on the object
137+
*/
138+
static EventListener[] getListeners(Object object, Class type)
139+
throws Exception {
140+
Method methods[] = object.getClass().getMethods();
141+
Method method = null;
142+
143+
for (int nmethod = 0; nmethod < methods.length; nmethod++) {
144+
if (methods[nmethod].getName().equals("getListeners")) {
145+
method = methods[nmethod];
146+
break;
147+
}
148+
}
149+
if (method == null) {
150+
throw new RuntimeException("Object "
151+
+ object + " has no getListeners method");
152+
}
153+
Class params[] = {type};
154+
EventListener listeners[] = null;
155+
listeners = (EventListener[]) method.invoke(object, params);
156+
System.out.println("Listeners of type: " + type + " on " + object);
157+
GetListenersTest.printArray(listeners);
158+
return listeners;
159+
}
160+
161+
/*
162+
* Adds a listener of every type to the object
163+
*/
164+
static void addDummyListenersOfEveryType(Object object) throws Exception {
165+
Class type = object.getClass();
166+
167+
BeanInfo info = Introspector.getBeanInfo(type);
168+
EventSetDescriptor esets[] = info.getEventSetDescriptors();
169+
170+
// add every kind of listener
171+
for (int nset = 0; nset < esets.length; nset++) {
172+
Class listenerType = esets[nset].getListenerType();
173+
EventListener listener = makeListener(listenerType);
174+
Method addListenerMethod = esets[nset].getAddListenerMethod();
175+
Object params[] = {listener};
176+
addListenerMethod.invoke(object, params);
177+
}
178+
}
179+
180+
/*
181+
* Determines what listeners to exclude from the test for now
182+
*/
183+
static boolean validListenerToTest(Class listenerType) {
184+
/* Don't have any provision for PropertyChangeListeners... */
185+
if ( listenerType == PropertyChangeListener.class ) {
186+
return false;
187+
}
188+
189+
return true;
190+
}
191+
192+
static void testGetListeners(Object object) throws Exception {
193+
GetListenersTest.addDummyListenersOfEveryType(object);
194+
GetListenersTest.checkForListenersOfEveryType(object);
195+
}
196+
197+
static void printArray(Object objects[]) {
198+
System.out.println("{");
199+
for(int n = 0; n < objects.length; n++) {
200+
System.out.println("\t"+objects[n]+",");
201+
}
202+
System.out.println("}");
203+
}
204+
205+
/*
206+
* Makes a dummy listener implementation for the given listener type
207+
*/
208+
static EventListener makeListener(Class listenerType) throws Exception {
209+
Object map[][] = {
210+
{ActionListener.class, MyActionAdapter.class},
211+
{AdjustmentListener.class, MyAdjustmentAdapter.class},
212+
{ComponentListener.class, MyComponentAdapter.class},
213+
{ContainerListener.class, MyContainerAdapter.class},
214+
{FocusListener.class, MyFocusAdapter.class},
215+
{HierarchyBoundsListener.class, MyHierarchyBoundsAdapter.class},
216+
{HierarchyListener.class, MyHierarchyAdapter.class},
217+
{InputMethodListener.class, MyInputMethodAdapter.class},
218+
{ItemListener.class, MyItemAdapter.class},
219+
{KeyListener.class, MyKeyAdapter.class},
220+
{MouseListener.class, MyMouseAdapter.class},
221+
{MouseMotionListener.class, MyMouseMotionAdapter.class},
222+
{MouseWheelListener.class, MyMouseWheelAdapter.class},
223+
{TextListener.class, MyTextAdapter.class},
224+
{WindowListener.class, MyWindowAdapter.class},
225+
{WindowFocusListener.class, MyWindowFocusAdapter.class},
226+
{WindowStateListener.class, MyWindowStateAdapter.class},
227+
{PropertyChangeListener.class, MyPropertyChangeAdapter.class},
228+
};
229+
230+
for (int n = 0; n < map.length; n++) {
231+
if (map[n][0] == listenerType) {
232+
Class adapterClass = (Class) map[n][1];
233+
EventListener listener =
234+
(EventListener) adapterClass.newInstance();
235+
return listener;
236+
}
237+
}
238+
239+
throw new RuntimeException("No adapter found for listener type "
240+
+ listenerType);
241+
}
242+
}
243+
244+
class GLTFrame extends Frame {
245+
MenuItem mitem;
246+
CheckboxMenuItem cmitem;
247+
248+
GLTFrame() {
249+
super("Component.getListeners API Test");
250+
}
251+
252+
public void initAndShowGui() {
253+
setLayout(new FlowLayout());
254+
255+
add(new Label("Label"));
256+
add(new Button("Button"));
257+
add(new Checkbox("Checkbox"));
258+
Choice c = new Choice();
259+
c.add("choice");
260+
java.awt.List l = new java.awt.List();
261+
l.add("list");
262+
add(new Scrollbar());
263+
add(new TextField("TextField"));
264+
add(new TextArea("TextArea"));
265+
add(new Panel());
266+
add(new Canvas());
267+
268+
MenuBar menuBar = new MenuBar();
269+
Menu menu = new Menu("Menu");
270+
mitem = new MenuItem("Item 1");
271+
cmitem = new CheckboxMenuItem("Item 2");
272+
menu.add(mitem);
273+
menu.add(cmitem);
274+
menuBar.add(menu);
275+
setMenuBar(menuBar);
276+
277+
pack();
278+
setVisible(true);
279+
}
280+
281+
public void test() throws Exception {
282+
// test Frame.getListeners
283+
GetListenersTest.testGetListeners(this);
284+
285+
//
286+
// test getListeners on menu items
287+
//
288+
GetListenersTest.testGetListeners(mitem);
289+
GetListenersTest.testGetListeners(cmitem);
290+
291+
//
292+
// test getListeners on all AWT Components
293+
//
294+
Component components[] = getComponents();
295+
for (int nc = 0; nc < components.length; nc++) {
296+
GetListenersTest.testGetListeners(components[nc]);
297+
}
298+
}
299+
}
300+
301+
/************************************************
302+
* Dummy listener implementations we add to our components/models/objects
303+
*/
304+
305+
class MyPropertyChangeAdapter implements PropertyChangeListener {
306+
public void propertyChange(PropertyChangeEvent evt) {}
307+
}
308+
309+
class MyActionAdapter implements ActionListener {
310+
public void actionPerformed(ActionEvent ev) {
311+
}
312+
}
313+
314+
class MyAdjustmentAdapter implements AdjustmentListener {
315+
public void adjustmentValueChanged(AdjustmentEvent e) {
316+
}
317+
}
318+
319+
class MyHierarchyAdapter implements HierarchyListener {
320+
public void hierarchyChanged(HierarchyEvent e) {
321+
}
322+
}
323+
324+
class MyInputMethodAdapter implements InputMethodListener {
325+
public void inputMethodTextChanged(InputMethodEvent event) {
326+
}
327+
328+
public void caretPositionChanged(InputMethodEvent event) {
329+
}
330+
}
331+
332+
class MyItemAdapter implements ItemListener {
333+
public void itemStateChanged(ItemEvent e) {
334+
}
335+
}
336+
337+
class MyTextAdapter implements TextListener {
338+
public void textValueChanged(TextEvent e) {
339+
}
340+
}
341+
342+
class MyComponentAdapter extends ComponentAdapter {
343+
}
344+
345+
class MyContainerAdapter extends ContainerAdapter {
346+
}
347+
348+
class MyFocusAdapter extends FocusAdapter {
349+
}
350+
351+
class MyHierarchyBoundsAdapter extends HierarchyBoundsAdapter {
352+
}
353+
354+
class MyKeyAdapter extends KeyAdapter {
355+
}
356+
357+
class MyMouseAdapter extends MouseAdapter {
358+
}
359+
360+
class MyMouseMotionAdapter extends MouseMotionAdapter {
361+
}
362+
363+
class MyMouseWheelAdapter implements MouseWheelListener {
364+
public void mouseWheelMoved(MouseWheelEvent e) {}
365+
}
366+
367+
class MyWindowAdapter extends WindowAdapter {
368+
}
369+
370+
class MyWindowFocusAdapter implements WindowFocusListener {
371+
public void windowGainedFocus(WindowEvent t) {}
372+
public void windowLostFocus(WindowEvent t) {}
373+
}
374+
375+
class MyWindowStateAdapter extends WindowAdapter {
376+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
@test
26+
@bug 4852790
27+
@summary Frame disposal must remove opened popup without exception
28+
@key headful
29+
*/
30+
31+
import java.awt.BorderLayout;
32+
import java.awt.Dimension;
33+
import java.awt.EventQueue;
34+
import java.awt.FlowLayout;
35+
import java.awt.Point;
36+
import java.awt.Robot;
37+
import java.awt.event.InputEvent;
38+
import java.awt.event.WindowAdapter;
39+
import java.awt.event.WindowEvent;
40+
import javax.swing.JComboBox;
41+
import javax.swing.JFrame;
42+
import javax.swing.JMenuBar;
43+
import javax.swing.JPanel;
44+
45+
46+
public class OpenedPopupFrameDisposal {
47+
public static final int SIZE = 300;
48+
49+
volatile JFrame jf = null;
50+
volatile JComboBox<String> jcb = null;
51+
52+
public void start() {
53+
jf = new JFrame("OpenedPopupFrameDisposal - Frame to dispose");
54+
// Note that original bug cannot be reproduced without JMenuBar present.
55+
jf.setJMenuBar(new JMenuBar());
56+
jf.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
57+
jf.setLocationRelativeTo(null);
58+
jf.addWindowListener(new WindowAdapter() {
59+
public void windowClosing(WindowEvent evt) {
60+
jf.setVisible(false);
61+
jf.dispose();
62+
}
63+
});
64+
65+
66+
JPanel panel = new JPanel(new FlowLayout());
67+
jcb = new JComboBox<>();
68+
jcb.addItem("one");
69+
jcb.addItem("two");
70+
jcb.addItem("Three");
71+
panel.add(jcb);
72+
73+
jf.getContentPane().add(panel, BorderLayout.CENTER);
74+
jf.pack();
75+
jf.setSize(new Dimension(SIZE, SIZE));
76+
77+
jf.setVisible(true);
78+
79+
}
80+
81+
public void test() throws Exception {
82+
Robot robot = new Robot();
83+
robot.delay(1000); // wait for jf visible
84+
Point pt = jf.getLocationOnScreen();
85+
86+
int x, y;
87+
88+
x = pt.x + SIZE / 2;
89+
y = pt.y + SIZE / 2;
90+
91+
robot.mouseMove(x, y);
92+
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
93+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
94+
robot.delay(1000);
95+
96+
pt = jcb.getLocationOnScreen();
97+
x = pt.x + jcb.getWidth() / 2;
98+
y = pt.y + jcb.getHeight() / 2;
99+
100+
robot.mouseMove(x, y);
101+
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
102+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
103+
robot.delay(1000);
104+
105+
// Here on disposal we had a NullPointerException
106+
EventQueue.invokeAndWait(() -> {
107+
if (jf != null) {
108+
jf.setVisible(false);
109+
jf.dispose();
110+
}
111+
});
112+
}
113+
114+
public static void main(String[] args) throws Exception {
115+
OpenedPopupFrameDisposal imt = new OpenedPopupFrameDisposal();
116+
try {
117+
EventQueue.invokeAndWait(imt::start);
118+
imt.test();
119+
} finally {
120+
EventQueue.invokeAndWait(() -> {
121+
if (imt.jf != null) {
122+
imt.jf.dispose();
123+
}
124+
});
125+
}
126+
}
127+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
@test
26+
@bug 4546535
27+
@summary java.awt.Container.remove(int) throws unexpected NPE
28+
*/
29+
30+
import java.awt.Canvas;
31+
import java.awt.Panel;
32+
33+
public class RemoveByIndexExceptionTest {
34+
35+
public static void main(String[] args) throws Exception {
36+
Panel p = new Panel();
37+
p.add(new Canvas());
38+
p.remove(0);
39+
40+
int[] bad = {-1, 0, 1};
41+
for (int i = 0; i < bad.length; i++) {
42+
try {
43+
System.out.println("Removing " + bad[i]);
44+
p.remove(bad[i]);
45+
System.out.println("No exception");
46+
} catch (ArrayIndexOutOfBoundsException e) {
47+
e.printStackTrace();
48+
System.out.println("This is correct exception - " + e);
49+
} catch (NullPointerException e) {
50+
e.printStackTrace();
51+
throw new RuntimeException("Test Failed: NPE was thrown.");
52+
}
53+
}
54+
System.out.println("Test Passed.");
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
@test
26+
@bug 4924516
27+
@summary Verifies that SHOWING_CHANGED event is propagated to \
28+
HierarchyListeners then toolkit enabled
29+
@key headful
30+
*/
31+
32+
33+
import java.awt.AWTEvent;
34+
import java.awt.EventQueue;
35+
import java.awt.Toolkit;
36+
import java.awt.event.AWTEventListener;
37+
import java.awt.event.HierarchyEvent;
38+
import java.awt.event.HierarchyListener;
39+
import javax.swing.JButton;
40+
import javax.swing.JFrame;
41+
import javax.swing.JPanel;
42+
43+
public class ShowingChangedEventTest
44+
implements AWTEventListener, HierarchyListener{
45+
private boolean eventRegisteredOnButton = false;
46+
47+
private final JFrame frame = new JFrame("ShowingChangedEventTest");
48+
private final JPanel panel = new JPanel();
49+
private final JButton button = new JButton();
50+
51+
52+
public static void main(String[] args) throws Exception {
53+
EventQueue.invokeAndWait(() -> {
54+
ShowingChangedEventTest showingChangedEventTest
55+
= new ShowingChangedEventTest();
56+
57+
try {
58+
showingChangedEventTest.start();
59+
} finally {
60+
showingChangedEventTest.frame.dispose();
61+
}
62+
});
63+
}
64+
65+
public void start () {
66+
frame.getContentPane().add(panel);
67+
panel.add(button);
68+
69+
frame.pack();
70+
frame.setVisible(true);
71+
72+
Toolkit.getDefaultToolkit()
73+
.addAWTEventListener(this, AWTEvent.HIERARCHY_EVENT_MASK);
74+
75+
button.addHierarchyListener(this);
76+
panel.setVisible(false);
77+
78+
if (!eventRegisteredOnButton){
79+
throw new RuntimeException("Event wasn't registered on Button.");
80+
}
81+
}
82+
83+
@Override
84+
public void eventDispatched(AWTEvent awtevt) {
85+
if (awtevt instanceof HierarchyEvent) {
86+
HierarchyEvent hevt = (HierarchyEvent) awtevt;
87+
if (hevt != null && (hevt.getChangeFlags()
88+
& HierarchyEvent.SHOWING_CHANGED) != 0) {
89+
System.out.println("Hierarchy event was received on Toolkit. "
90+
+ "SHOWING_CHANGED for "
91+
+ hevt.getChanged().getClass().getName());
92+
}
93+
}
94+
}
95+
96+
@Override
97+
public void hierarchyChanged(HierarchyEvent e) {
98+
if ((HierarchyEvent.SHOWING_CHANGED & e.getChangeFlags()) != 0) {
99+
System.out.println("Hierarchy event was received on Button. "
100+
+ "SHOWING_CHANGED for "
101+
+ e.getChanged().getClass().getName());
102+
}
103+
eventRegisteredOnButton = true;
104+
}
105+
}

0 commit comments

Comments
 (0)
Please sign in to comment.