JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java SE 討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 不能resize 沒有最大最小按鈕的 JFrame [精華]
liminjun

JavaDOCHelper真讚



發文: 496
積分: 5
於 2004-01-22 08:54 user profilesend a private message to usersend email to liminjunreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1.沒有最大最小化按鈕,也不能改變大小的 JInternalFrame 只要用建構子的參數即可,如果是 JFrame (主視窗) 呢? 要怎麼才能做到?

2.如何做出一個透明的視窗呢(為了製作不規則邊緣的視窗) ?


liminjun edited on 2004-01-22 09:24
reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
liminjun

JavaDOCHelper真讚



發文: 496
積分: 5
於 2004-01-22 09:01 user profilesend a private message to usersend email to liminjunreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
frame.setResizable( false ); 可以讓視窗無法改變大小
但是如何讓最大最小化按鈕根本不出現呢?


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
Duncan

還隱隱作痛

版主

發文: 7816
積分: 39
於 2004-01-22 11:40 user profilesend a private message to usersend email to Duncanreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
liminjun wrote:
frame.setResizable( false ); 可以讓視窗無法改變大小
但是如何讓最大最小化按鈕根本不出現呢?


請使用 Dialog/JDialog。就一般使用的觀點,一個 non-modal dialog 和 frame 沒兩樣。


reply to postreply to post

給我
辣味豆腐 其餘免談
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
liminjun

JavaDOCHelper真讚



發文: 496
積分: 5
於 2004-01-22 11:59 user profilesend a private message to usersend email to liminjunreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
如何做出一個透明的視窗呢(為了製作不規則邊緣的視窗) ?

reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
Duncan

還隱隱作痛

版主

發文: 7816
積分: 39
於 2004-01-22 12:23 user profilesend a private message to usersend email to Duncanreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
liminjun wrote:
如何做出一個透明的視窗呢(為了製作不規則邊緣的視窗) ?


這只能求助 JNI,透過 native library 去使用各 OS 平台提供的支援。使用了 JNI 代表你必須把同樣的一件事作很多遍(不同平台有不同的做法),而你還不見得有這能力。Skin Look And Feel 作者有提供一套 JNI 的做法(有 Windows DLL),你可以 survey 看看。

我曾想過純 Java 的做法是:不要使用 Frame 的 decoration(或是使用 Window),然後搭配 java.awt.Robot 來抓取桌面的影像,你以抓到的影像當作你的視窗的背景,可以模擬透明視窗,但是這樣做很麻煩,每次改變視窗位置與大小都得作一次這樣的步驟,在支援視窗平滑移動的 OS 上,你勢必會漏出馬腳。


reply to postreply to post

給我
辣味豆腐 其餘免談
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
liminjun

JavaDOCHelper真讚



發文: 496
積分: 5
於 2004-01-22 15:32 user profilesend a private message to usersend email to liminjunreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
舉個圖例好了,小弟並不是要實作一個完整的 LookAndFeel
而是類似這樣子的一個視窗

我的想法是,讓整個視窗都是透明& 把標題列關閉
然後用 Lable 或 Pane 把圖像元件等等的東西擺上去,自然會變成這樣子的視窗,我現在問題卡在,我把 contentPane 和 LayeredPane GlassPane 都設定成透明了,但是仍然會有一層 白底色


liminjun edited on 2004-01-22 15:35
reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
Duncan

還隱隱作痛

版主

發文: 7816
積分: 39
於 2004-01-22 16:44 user profilesend a private message to usersend email to Duncanreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
liminjun wrote:
舉個圖例好了,小弟並不是要實作一個完整的 LookAndFeel
而是類似這樣子的一個視窗



我給你的是 LAF 的網址沒錯,但重要的是作者有用 JNI 作一個可在 Windows platform 使用透明視窗的套件(叫 SkinRegion 來的可以作透明/半透明視窗以及 always on top 的視窗,包含在 laf 套件裡,有 demo 可以先看看)。我自己在 Windows2000 + jdk1.4.1 上試過似乎不是很理想(會有殘像的問題)。

目前要作透明視窗只能透過 JNI,使用 C/C++ 語言去向 OS 要透明的視窗。AWT 提供的 top level Container(Window/Frame) 都一定是 opaque。

(縮略圖,點擊圖片鏈接看原圖)


reply to postreply to post

給我
辣味豆腐 其餘免談
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
liminjun

JavaDOCHelper真讚



發文: 496
積分: 5
於 2004-01-22 17:18 user profilesend a private message to usersend email to liminjunreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
感謝您提供這樣的訊息,這真的是滿有用的,而且該網站還有example 檔案可以看,不過這裡有個小問題,您知道哪裡可以下載的到skinlf-1.2.7的api doc 文件?? 我目前僅看到網頁上的,沒找到打包好的,查資料有點不方便

reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
Duncan

還隱隱作痛

版主

發文: 7816
積分: 39
於 2004-01-22 17:40 user profilesend a private message to usersend email to Duncanreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
liminjun wrote:
感謝您提供這樣的訊息,這真的是滿有用的,而且該網站還有example 檔案可以看,不過這裡有個小問題,您知道哪裡可以下載的到skinlf-1.2.7的api doc 文件?? 我目前僅看到網頁上的,沒找到打包好的,查資料有點不方便


我也沒有找到相關的文件(javadoc 有 online 的)。

我唯一下載到的文件只有這個。

documentation.pdf (347.22k)


reply to postreply to post

給我
辣味豆腐 其餘免談
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
liminjun

JavaDOCHelper真讚



發文: 496
積分: 5
於 2004-01-22 17:50 user profilesend a private message to usersend email to liminjunreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我執行java -classpath "nativeskin.jar;examples.jar" examples.nativesplash 的時候碰到一個問題,下有附圖,請問這該如何解決?


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
Duncan

還隱隱作痛

版主

發文: 7816
積分: 39
於 2004-01-22 17:54 user profilesend a private message to usersend email to Duncanreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
liminjun wrote:
我執行java -classpath "nativeskin.jar;examples.jar" examples.nativesplash 的時候碰到一個問題,下有附圖,請問這該如何解決?


把套件裡的 dll 所在目錄加到 path 環境參數,並使用 JDK 所附的 JRE(use JDK\jre\bin 下的 java.exe)。

我實際跑過,殘像真的蠻嚴重的。如果你有 Windows programming 的經驗,或許可以考慮自己用 JNI 做做看。


reply to postreply to post

給我
辣味豆腐 其餘免談
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:Duncan]
liminjun

JavaDOCHelper真讚



發文: 496
積分: 5
於 2004-01-22 18:04 user profilesend a private message to usersend email to liminjunreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Duncan wrote:
把套件裡的 dll 所在目錄加到 path 環境參數,並使用 JDK 所附的 JRE(use JDK\jre\bin 下的 java.exe)。

我實際跑過,殘像真的蠻嚴重的。如果你有 Windows programming 的經驗,或許可以考慮自己用 JNI 做做看。


問題出在於 必須使用  JDK 所附的 JRE(use JDK\jre\bin 下的 java.exe),目前已經解決,不過跟您說的一樣,殘像好嚴重

請問還有什麼替代方案呢?


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
T55555

Java, Ruby, Haskell

版主

發文: 1026
積分: 24
於 2004-01-23 06:35 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Here is an example of using JNI ...

Java Tip 86: Support native rendering in JDK 1.3
http://www.javaworld.com/javaworld/javatips/jw-javatip86.html


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
rfus





發文: 315
積分: 2
於 2004-01-23 09:32 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
怎麼做LookAndFeel??

reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:T55555]
liminjun

JavaDOCHelper真讚



發文: 496
積分: 5
於 2004-01-23 11:42 user profilesend a private message to usersend email to liminjunreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
T55555 wrote:
Here is an example of using JNI ...

Java Tip 86: Support native rendering in JDK 1.3
http://www.javaworld.com/javaworld/javatips/jw-javatip86.html


感謝您提供資訊
不過這是直接在c++程式內繪圖,然後用java直接呼叫,如果僅僅只是想讓整個視窗變成透明,繪圖動作由java程式自己完成,有辦法這樣嗎?


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
T55555

Java, Ruby, Haskell

版主

發文: 1026
積分: 24
於 2004-01-23 23:28 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
liminjun wrote:
感謝您提供資訊
不過這是直接在c++程式內繪圖,然後用java直接呼叫,如果僅僅只是想讓整個視窗變成透明,繪圖動作由java程式自己完成,有辦法這樣嗎?


Here are more information about native window stuff,
they are NOT related the L&F you are looking,
but they maybe give you some ideas...

Make Your Swing App Go Native, Part 1
http://today.java.net/pub/a/today/2003/12/08/swing.html

Make Your Swing App Go Native, Part 2
http://today.java.net/pub/a/today/2004/01/05/swing.html

Most of time, I just use Skin Look and Feel.
The irregular window shape is not cross-platform,
that is why the Skin L&F for irregular window shape support
is only on M$ win platform!

I do have an idea, but never try it...
My idea is: Since Java Swing support double buffering,
swing component can draw on buffered Image,
You could make all swing drawing on buffered Image,
then pass the buffered image to JNI level,
the JNI level clip the image to fit the native window shape ... etc
(but for real-time image, this will too slow, and we back to Skin L&F problem again...)


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:rfus]
T55555

Java, Ruby, Haskell

版主

發文: 1026
積分: 24
於 2004-01-23 23:34 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
rfus wrote:
怎麼做LookAndFeel??


short question.... Mmmm.... short answer too:

Go To : (Nice free Swing book !!)
http://manning.spindoczine.com/sbe/

And read the :
Chapter 21: Pluggable Look and Feel


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:rfus]
liminjun

JavaDOCHelper真讚



發文: 496
積分: 5
於 2004-01-24 11:21 user profilesend a private message to usersend email to liminjunreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
rfus wrote:
怎麼做LookAndFeel??


如果您僅是想問如何使用的話,請參考
http://javaalmanac.com/egs/javax.swing/LookFeel.html
http://javaalmanac.com/egs/javax.swing/LookFeelNative.html


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
rfus





發文: 315
積分: 2
於 2004-01-24 13:15 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
當然不是啊...
我都用這行...短短一行...設定成window style
1
try{UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");}catch(Exception e){}

我想問的是lookandfeel可以自己做哦?如何做呢?


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:rfus]
liminjun

JavaDOCHelper真讚



發文: 496
積分: 5
於 2004-01-24 13:58 user profilesend a private message to usersend email to liminjunreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
rfus wrote:
當然不是啊...
我都用這行...短短一行...設定成window style
1
try{UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");}catch(Exception e){}

我想問的是lookandfeel可以自己做哦?如何做呢?


swing 實作手冊(2e) 有中譯本 裡面的第21張有大概的說到,不過似乎不怎麼容易呢 Embaressed 感覺很難, swing 的英文第一版網路上可以免費閱讀


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
willon





發文: 1
積分: 0
於 2004-06-05 15:39 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在frame.setVisible(true)前加上frame.setUndecorated(true)

此时的frame如同一个logo界面。


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
Maxyang





發文: 5
積分: 0
於 2004-10-03 18:41 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
String lookAndFeel[];
lookAndFeel=new String[3];
//Java风格
lookAndFeel[0]="javax.swing.plaf.metal.MetalLookAndFeel";
lookAndFeel[1]="com.sun.java.swing.plaf.motif.MotifLookAndFeel";
//Windows 风格
lookAndFeel[2]="com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
try{UIManager.setLookAndFeel(lookAndFeel[0]);
SwingUtilities.updateComponentTreeUI(this);}
catch (Exception ee){}
还有一种是Mac系统的没写,我没用过.在Windows下测试会出错,还有一定要用数组,当然直接放到setLookAndFeel()里也可以


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
fangxia





發文: 1
積分: 0
於 2005-04-25 11:27 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
为什么不试试SWT呢。。

reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
flywasp





發文: 1
積分: 0
於 2005-07-01 14:22 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
JFrame mframe = new JFrame();
mframe.setUndecorated(true); //取消JFrame的外觀描繪

這樣就可以讓它啥都沒有囉,真的是什麼都沒有...
JFrame會變成一個空的架子
它的Size就必須要設定,不然在上面做一些事情就可能產生Exception

JAVA的新手,請大家多多指教囉


reply to postreply to post
作者 Re:不能resize 沒有最大最小按鈕的 JFrame [Re:liminjun]
bloffice

居安思危



發文: 66
積分: 0
於 2007-11-06 14:51 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
ooo

reply to postreply to post
善始善終
go to first page go to previous page  1   2  go to next page go to last page
» JWorld@TW »  Java SE 討論區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8