package javaapplication1;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class JavaApplication1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.setTitle("Frame");
frame.setSize(800, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
device.setFullScreenWindow(frame);
device.setDisplayMode(new DisplayMode(800, 600, 32, 60));
frame.setVisible(true);
JButton btn = new JButton();
btn.setText("Button");
JPanel panel = new JPanel();
panel.add(btn);
frame.add(panel);
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(frame, "JOptionPane");
}
});
}
}
當我按一下按鈕,它被設置爲全屏應用程序將進入任務欄/最小化,所以我需要先點擊它在任務欄上看到我觸發的JOptionPane之前。你認爲這是什麼問題?我希望它能夠順利運行而不會被最小化或轉到任務欄。期待您的答案。提前致謝。或者還有其他的選擇嗎?的JOptionPane的JFrame外面顯示與GraphicsDevice的
好的,這是新的。 :) – Jong
1件事情不需要在set中設置setVisible(true)作爲setFullScreenWindow(frame);'將幀設置爲可見,如果它不是。與此說,我也會移動此調用後,所有組件添加到JFrame不是解決了問題,但減少了可能的原因 –
@DavidKroukamp,我刪除了我的舊問題。只是我希望它得到回答,而不是被遺忘。 – Jong