< prev index next >
test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java
Print this page
*** 19,30 ****
* 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.
*/
! import javax.swing.*;
! import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/*
* @test
--- 19,43 ----
* 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.
*/
! import javax.swing.JComponent;
! import javax.swing.JPanel;
! import javax.swing.RootPaneContainer;
! import javax.swing.JList;
! import javax.swing.JComboBox;
! import javax.swing.JPopupMenu;
! import javax.swing.event.PopupMenuEvent;
! import javax.swing.event.PopupMenuListener;
! import java.awt.GraphicsDevice;
! import java.awt.Container;
! import java.awt.BorderLayout;
! import java.awt.Point;
! import java.awt.Color;
! import java.awt.Window;
! import java.awt.EventQueue;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/*
* @test
*** 51,60 ****
--- 64,75 ----
JComponent south;
JComponent center;
JPanel north;
volatile boolean southClicked = false;
+ JPopupMenu popup = null;
+
public static void main(String[] args) throws Exception {
if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))
for (Class<Window> windowClass: WINDOWS_TO_TEST)
new TranslucentJComboBox(windowClass).doTest();
}
*** 82,91 ****
--- 97,124 ----
JComboBox jComboBox = new JComboBox();
for(int i = 0; i < 20; i++) {
jComboBox.addItem("item " + i);
}
south = jComboBox;
+ jComboBox.addPopupMenuListener(new PopupMenuListener() {
+
+ @Override
+ public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
+ popup = (JPopupMenu) jComboBox.getUI()
+ .getAccessibleChild(jComboBox, 0);
+ }
+
+ @Override
+ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
+
+ }
+
+ @Override
+ public void popupMenuCanceled(PopupMenuEvent e) {
+
+ }
+ });
south.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
southClicked = true;
*** 140,150 ****
throw new RuntimeException(
"Check for opaque drop down failed at point " + p1 +
". Before click: " + c1 + ", after click: " + c1b +
", expected is " + south.getBackground());
! if (!c2.equals(c2b) && !south.getBackground().equals(c2b))
throw new RuntimeException(
"Check for opaque drop down failed at point " + p2 +
". Before click: " + c2 + ", after click: " + c2b +
", expected is " + south.getBackground());
--- 173,189 ----
throw new RuntimeException(
"Check for opaque drop down failed at point " + p1 +
". Before click: " + c1 + ", after click: " + c1b +
", expected is " + south.getBackground());
! //This following check is only valid if the popup was created below the
! // JComboBox and will be opaque or it is created above the JComboBox
! // and it can not fit inside the JWindow along with JComboBox and will
! // be opaque
! if ( !c2.equals(c2b) && !south.getBackground().equals(c2b) &&
! (popup.getLocationOnScreen().y > ls.y ||
! window.getHeight() < popup.getHeight() + south.getHeight()))
throw new RuntimeException(
"Check for opaque drop down failed at point " + p2 +
". Before click: " + c2 + ", after click: " + c2b +
", expected is " + south.getBackground());
< prev index next >