當我點擊按鈕時,設置爲全屏的應用程序將進入任務欄/最小化,因此我需要在任務欄中首先單擊它,然後才能看到我觸發的JOptionPane
。你認爲這是什麼問題?我希望它能夠順利運行而不會被最小化或轉到任務欄。這裏GrahicsDevice和JOptionPane問題
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.setTitle("Sample");
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("Btn");
JPanel panel = new JPanel();
panel.add(btn);
frame.add(panel);
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(frame, "Sample");
throw new UnsupportedOperationException("Not supported yet.");
}
});
}
我該如何接受答案? – Jong
閱讀此[鏈接](http://meta.stackexchange.com/a/65088/155831)。您可以重新訪問以前的問題並接受。 – Reimeus
你嘗試過'JDialog'而不是'JOptionPane'嗎? –