回答
爲了使程序全屏使用;
window.setExtendedState(Frame.MAXIMIZED_BOTH); //maximise window
window.setUndecorated(true); //remove decorations e.g. x in top right
並使窗口始終處於最佳使用狀態(阻止使用其他正在運行的程序的人員);
window.setAlwaysOnTop(true);
謝謝Ste T :) – 2010-12-16 15:41:10
最大化窗口是否阻止訪問窗口任務欄?如果你的窗口始終處於最佳狀態,它是否會掩蓋後面可能會出現的任何模態對話框? – Curtis 2010-12-16 15:41:16
如果窗口失去焦點,任務欄確實變得可見,但是您可以使用機器人在窗口失去焦點時單擊以進行修復:D – 2010-12-16 15:45:27
您不能在Java級別上做到這一點 - 您需要將操作系統設置爲某種「Kiosk模式」。
不請自來的評論 - 你是否需要這個,是因爲你(或你的客戶)討厭你的用戶,並希望他們永遠詛咒你?您是否打算將「關閉計算機」功能添加到您的程序中?
+1爲未經請求的評論。我會很快卸載這樣一個程序。 – 2010-12-16 15:42:58
也許這是某種公共終端或某種程序。我很難想象爲什麼在普通的臺式電腦或筆記本電腦上需要這樣的程序。 – 2010-12-16 15:56:56
如果您正在尋找全屏支持,這是我使用的代碼。應該足以讓你走了。您只需要一個全局布爾變量來說明應用程序是否全屏。你可以用它來修補它,讓它顯示你喜歡的。
/**
* Method allows changing whether this window is displayed in fullscreen or
* windowed mode.
* @param fullscreen true = change to fullscreen,
* false = change to windowed
*/
public void setFullscreen(boolean fullscreen)
{
//get a reference to the device.
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
DisplayMode dispMode = device.getDisplayMode();
//save the old display mode before changing it.
dispModeOld = device.getDisplayMode();
if(this.fullscreen != fullscreen)
{ //are we actually changing modes.
//change modes.
this.fullscreen = fullscreen;
// toggle fullscreen mode
if(!fullscreen)
{
//change to windowed mode.
//set the display mode back to the what it was when
//the program was launched.
device.setDisplayMode(dispModeOld);
//hide the frame so we can change it.
setVisible(false);
//remove the frame from being displayable.
dispose();
//put the borders back on the frame.
setUndecorated(false);
//needed to unset this window as the fullscreen window.
device.setFullScreenWindow(null);
//recenter window
setLocationRelativeTo(null);
setResizable(true);
//reset the display mode to what it was before
//we changed it.
setVisible(true);
}
else
{ //change to fullscreen.
//hide everything
setVisible(false);
//remove the frame from being displayable.
dispose();
//remove borders around the frame
setUndecorated(true);
//make the window fullscreen.
device.setFullScreenWindow(this);
//attempt to change the screen resolution.
device.setDisplayMode(dispMode);
setResizable(false);
setAlwaysOnTop(false);
//show the frame
setVisible(true);
}
//make sure that the screen is refreshed.
repaint();
}
}
不錯:)感謝很多朋友... – 2010-12-16 15:41:51
這是一個非常廣泛的應用程序全屏幕的方式。大多數其他指南只包括'device.setFullScreenWindow(this);'但這可能會留下不需要的邊緣。我會親自刪除'setLocationRelativeTo(null);'雖然窗口似乎記得它的舊位置,並會返回到它。 – Finnboy11 2014-05-01 14:15:24
- 1. JFileChooser在全屏幕Swing應用程序
- 2. 將SWING組件放置在Java全屏應用程序中的最佳實踐?
- 3. Swing中的全屏框架
- 4. Java Fx全屏應用程序
- 5. Java Swing程序結構
- 6. Java Swing簡單程序
- 7. Java Swing實用程序
- 8. 程序Java Swing,Flex像
- 9. 如何在觸摸屏上實現Java Swing應用程序
- 10. Java Swing應用程序 - Window 8平板電腦 - 屏幕鍵盤
- 11. Java Swing屏幕文物
- 12. Java Swing - 觸摸屏 - L&F
- 13. 如何在全屏模式下切換全屏Swing框?
- 14. java swing swing與多線程
- 15. 當屏幕保護程序打開時,全屏java應用程序最小化
- 16. Java Swing +線程
- 17. Tkinter全屏應用程序
- 18. 全屏C#應用程序
- 19. JFrame全屏Java
- 20. 在Swing中設置全屏顯示
- 21. 多線程Java Swing
- 22. Java Swing線程庫
- 23. 幫助Java程序(Swing +數據庫)
- 24. Java Swing按鈕凍結程序
- 25. netbeans + hibernate的java swing應用程序
- 26. 讓Java Swing程序再次佈局
- 27. 針對Java Swing應用程序的Spy ++
- 28. Swing桌面java應用程序滾動
- 29. 通過Java小程序使用FEST-Swing
- 30. Java Swing應用程序,在範圍
我不認爲你可以這樣做,而不訴諸依賴於平臺的JNI。一個很好的問題。 – 2010-12-16 15:37:35
你爲什麼要這麼做?運行多任務操作系統的重點在於人們可以做到這一點。 – DJClayworth 2010-12-16 15:54:59
看看:http://stackoverflow.com/questions/6127709/remove-the-possibility-of-using-alt-f4-and-alt-tab-in-java-gui?lq=1 – seewip 2012-07-25 14:06:57