。
GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
。
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException:
The effects for full-screen windows are not supported.
,或者使用brutte_force
到DirectX
凍結我的電腦twicw,只有POWER_OFF節省PC的GPU
import com.sun.awt.AWTUtilities;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class JFrameOpacityExample {
private JFrame myFrame = new JFrame("Test Frame");
private boolean opacity = true;
private boolean resize = true;
private JButton button = new JButton("Opacity");
private JButton button1 = new JButton("Resize");
public JFrameOpacityExample() {
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Object src = evt.getSource();
if (opacity) {
AWTUtilities.setWindowOpacity(myFrame, 0.50f);
opacity = false;
} else {
AWTUtilities.setWindowOpacity(myFrame, 1.0f);
opacity = true;
}
}
});
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Object src = evt.getSource();
if (resize) {
Rectangle dim = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
int h = dim.height;
int w = dim.width;
myFrame.setBounds(00, 00, w, h);
resize = false;
} else {
myFrame.setBounds(100, 100, 400, 400);
resize = true;
}
}
});
JPanel panel = new JPanel();
panel.add(button);
panel.add(button1);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.add(panel);
myFrame.setSize(400, 400);
myFrame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrameOpacityExample jFrameOpacityExample = new JFrameOpacityExample();
}
});
}
}
我簡要正在尋求在本週類似的東西。我曾希望創建一個彩色濾鏡。鼠標點擊需要擊中過濾器後面的項目而不是過濾器。我沒有太努力研究,所以如果有人知道那就太棒了! – mrswadge 2012-07-06 12:35:09
@mrswadge:您可以將鼠標偵聽器添加到您的窗口,然後在觸發鼠標事件時(例如單擊),切換窗口並使用java.awt.Robot來模擬事件(mousePress)。這解決了你的問題的一部分。讓我們希望他們解決關於真正全屏/透明度的部分。 – ccit 2012-07-06 12:41:43