透明窗口中的文本不是抗锯齿的

时间:2013-09-23 15:45:08

标签: java swing user-interface translucency

透明窗口中的文本(AWTUtilities.setWindowOpaque(window,false))未正确抗锯齿,并且在不透明窗口中看起来不同。

我正在使用JDK 7.40。

知道如何解决它吗?

在下面的程序中,按钮文本没有抗锯齿(正确)。删除setWindowOpaque()可修复抗锯齿。

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFrame;

import com.sun.awt.AWTUtilities;

public class TransparentFrame extends JFrame
{
    public TransparentFrame()
    {
        setUndecorated(true);
        AWTUtilities.setWindowOpaque(this, false);
        add(new JButton(new ExitAction()));
    }

    public static void main(String[] args)
    {
        JFrame frame = new TransparentFrame();
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    private class ExitAction extends AbstractAction
    {
        public ExitAction()
        {
            super("Exit");
        }

        @Override
        public void actionPerformed(ActionEvent e)
        {
            System.exit(0);
        }
    }
}

0 个答案:

没有答案
相关问题