Swing窗口Linux下不支持最大化問題

Swing窗口Linux下不支持最大化問題

摘自:https://www.linuxidc.com/Linux/2009-06/20519.htmlinux

[日期:2009-06-17] 來源:www.quanlei.com  做者:quanlei [字體:  ]
 
 

因爲最近一直在Linux下工做,今天遇到了Swing窗口不能最大化的問題,剛開始始終不得其解,最後在同事Windows平臺下測試才發現原來是我用Linux的緣由。測試

咱們設置Swing窗口最大化通常有三種方法字體

方法一:
JFrame frame =new JFrame();
frame.setSize(Toolkit.getDefaultToolkit().getScreenSize());
frame.setLocation(0,0);
frame.show();
方法二:
(JDK1.4以上)
JFrame frame =new JFrame();
frame.show();
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
方法三:
JFrame frame=new JFrame();
frame.show();
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(). setFullScreenWindow(frame);this

其中方法一和方法三基本上相似,並非真正的最大化,當你用這倆方法後,最大化按鈕同樣是能夠點的,而且最大化後可能會遮住部分界面。
方法二是比較正統的用法,可問題是它在Linux下不支持,而且是一個已知的Bug(Bug ID:6365898), 官方解釋是:htm

「Please note that the bug has been fixed in the JDK 7 b14 (see the Release
Fixed field above),
which means that the JDK 6 still contains this bug. And currently we don't
plan to fix it in the JDK 6.「因此要兼容只能取捨了,Windows平臺用方法二,Liunx平臺暫時只能用方法一或者方法三了,
不過能夠在方法一和方法三的基礎上作些調整,好比高度上減去任務欄的高度和寬度上減去滾動條的寬度,這樣就稍微好點了。get

相關文章
相關標籤/搜索