Skip to content
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

7110890: reg test TranslucentShapedFrameTest fails to create non-opaque frame #753

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 8 additions & 41 deletions test/jdk/java/awt/Window/TranslucentShapedFrameTest/TSFrame.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2020, 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 @@ -22,27 +22,24 @@
*/

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsDevice.WindowTranslucency;
import java.awt.GraphicsEnvironment;
import java.awt.RenderingHints;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Canvas;
import java.awt.Component;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.util.Random;
import java.awt.geom.Ellipse2D;
import javax.swing.JApplet;
import java.util.Random;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
Expand Down Expand Up @@ -107,31 +104,6 @@ public void paintComponent(Graphics g) {
setUndecorated(true);
}
}
private static class NonOpaqueJAppletFrame extends JFrame {
JPanel p;
NonOpaqueJAppletFrame() {
super("NonOpaque Swing JAppletFrame");
JApplet ja = new JApplet() {
public void paint(Graphics g) {
super.paint(g);
System.err.println("JAppletFrame paint called");
}
};
p = new JPanel() {
public void paintComponent(Graphics g) {
super.paintComponent(g);
render(g, getWidth(), getHeight(), true);
g.setColor(Color.red);
g.drawString("Non-Opaque Swing JFrame", 10, 15);
}
};
p.setDoubleBuffered(false);
p.setOpaque(false);
ja.add(p);
add(ja);
setUndecorated(true);
}
}
private static class NonOpaqueFrame extends Frame {
NonOpaqueFrame() {
super("NonOpaque AWT Frame");
Expand Down Expand Up @@ -177,7 +149,6 @@ public static Frame createGui(
if (useNonOpaque) {
if (useSwing) {
frame = new NonOpaqueJFrame();
// frame = new NonOpaqueJAppletFrame(gc);
} else {
frame = new NonOpaqueFrame();
}
Expand Down Expand Up @@ -224,11 +195,7 @@ public void mouseClicked(MouseEvent e) {
}
});
frame.setPreferredSize(new Dimension(800, 600));

if (useShape) {
frame.setUndecorated(true);
}

frame.setUndecorated(true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main fix, always use undecorated frames.

frame.setLocation(450, 10);
frame.pack();

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2020, 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 @@ -31,19 +31,19 @@
* @run main/manual/othervm TranslucentShapedFrameTest
* @run main/manual/othervm -Dsun.java2d.noddraw=true TranslucentShapedFrameTest
*/

import java.awt.Color;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsDevice.WindowTranslucency;
import java.awt.GraphicsEnvironment;
import java.awt.Shape;
import java.awt.geom.Ellipse2D;
import java.util.concurrent.CountDownLatch;

import javax.swing.JSlider;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class TranslucentShapedFrameTest extends javax.swing.JFrame {
Frame testFrame;
Expand Down Expand Up @@ -145,14 +145,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

createDisposeGrp.add(createFrameBtn);
createFrameBtn.setText("Create Frame");
createFrameBtn.setSelected(true);
createFrameBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
createFrameBtnActionPerformed(evt);
}
});

createDisposeGrp.add(disposeFrameBtn);
disposeFrameBtn.setSelected(true);
disposeFrameBtn.setEnabled(false);
disposeFrameBtn.setText("Dispose Frame");
disposeFrameBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Expand Down Expand Up @@ -268,6 +269,9 @@ private void disposeFrameBtnActionPerformed(java.awt.event.ActionEvent evt) {//G
testFrame.dispose();
testFrame = null;
}
disposeFrameBtn.setEnabled(false);
createFrameBtn.setEnabled(true);
useSwingCb.setEnabled(true);
}//GEN-LAST:event_disposeFrameBtnActionPerformed

private void createFrameBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createFrameBtnActionPerformed
Expand All @@ -277,6 +281,9 @@ private void createFrameBtnActionPerformed(java.awt.event.ActionEvent evt) {//GE
useSwingCb.isSelected(), shapedCb.isSelected(),
(transl < 100), nonOpaqueChb.isSelected(),
(float)transl/100f);
createFrameBtn.setEnabled(false);
disposeFrameBtn.setEnabled(true);
useSwingCb.setEnabled(false);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a usability cleanup - disable some buttons that are noop in some states.

}//GEN-LAST:event_createFrameBtnActionPerformed

private void passedBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_passedBtnActionPerformed
Expand Down