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。你认为这有什么问题?我希望它能够顺利运行,而不会被最小化或进入任务栏。期待您的回答。提前致谢。或者还有其他选择吗?