我知道如何创建一个半透明的窗口,但为了完整起见,我将其包括在内。
现在这就是我想要做的......
创建一个不透明度为 60% 的未装饰的 JFrame
软窗边缘。
参考上图,您可以看到边缘清晰且轮廓分明。我想让它们变软
给它一个圆角矩形。
我可以给出一个形状,AWTUtilities.setWindowShape(Window,Shape)
但我想知道如何创建一个圆角矩形。
创建 `BufferedImage` 的反射以用作背景
你为什么不用Photoshop?你可能会问,但是创建一个你想尝试用作背景的图像的反射是很乏味的。相反,我想知道是否有一种编程方式:
BufferedImage
JFrame
为原始缓冲图像的两倍帮助!!!
import java.awt.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import javax.swing.*;
public class ImageReflection extends JFrame{
public ImageReflection(){
ImageIcon baseIcon = new ImageIcon("src/images/mentalist-logo.png");
ImageIcon reflectIcon = new ImageIcon("src/images/mentalist-logo.png");
JLabel baseLabel = new JLabel(baseIcon);
JLabel reflectLabel = new JLabel();
Graphics2D g2D = (Graphics2D) reflectIcon.getImage().getGraphics();
g2D.rotate(180);
reflectLabel.setIcon(reflectIcon);
this.add(reflectLabel);
this.setVisible(true);
this.pack();
}
public static void main(String[] args) {
new ImageReflection();
}
}
我得到一个UnsupportedOperationException
at Graphics2D g2D = (Graphics2D) reflectIcon.getImage().getGraphics();
。
这是我将图像倒置的代码。