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

» JWorld@TW » Java SE 討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 Re:needs to be declared final?? [Re:missee]
Duncan

還隱隱作痛

版主

發文: 7816
積分: 39
於 2003-08-04 00:21 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
missee wrote:
sorry~~
有個問題~~
我現在想把JFrame的background改成black~
1
2
3
4
5
6
7
8
9
10
public static void main(String[] args)
     {    
      JFrame f = new JFrame("MoveCircle");    
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   
       //f.setSize(300, 300);    
      f.setBounds(300,200,300,300);
      f.setBackground(Color.black);
      f.getContentPane().add(new MoveCircle(100));    
       f.show();  
     }


所以我加入的f.setBackfround(Color.black);
但程式run的時候~~
有會"瞬間"變成黑的~然後馬上又變回灰色的了~
請問這是為什麼呢?
還是我的語法錯了?


JFrame 的 client 被 content pane 塞滿,如果沒有 menu bar 的話(實際上,JFrame 是被一個 root pane 塞滿,而 root pane 持有一個 content pane,其與 root pane 一樣大並位在 root pane 所使用的 layer pane 的最底層)。而預設的 content pane 是不透光的,所以會遮蔽 JFrame 的顏色(背景),於是你依然是看到 content pane 的背景色 - 灰色。

你可以改成設定 content pane 的背景色,效果和你要的一樣。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
            +-------------------------------+
            | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
            | ~''''''''''''''''''''''''''''~|
            | ~'mmmmmmmmmmmmmmmmmmmmmmmmmm'~|
            | ~'cccccccccccccccccccccccccc'~|
            | ~'cccccccccccccccccccccccccc'~|
            | ~'cccccccccccccccccccccccccc'~|
            | ~'cccccccccccccccccccccccccc'~|
            | ~'cccccccccccccccccccccccccc'~|
            | ~'cccccccccccccccccccccccccc'~|
            | ~''''''''''''''''''''''''''''~|
            | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
            +-------------------------------+
 
    --: JFrame/JWindow
    ~~: JRootPane
    '': layeredPane(JLayeredPane)
    mm: menu bar
    cc: contentPane(any Container base class)
 


Duncan edited on 2004-12-04 18:48
reply to postreply to post

給我
辣味豆腐 其餘免談
話題樹型展開
人氣 標題 作者 字數 發文時間
6857 needs to be declared final?? missee 1957 2003-07-31 22:14
5565 Re:needs to be declared final?? Yoshi 441 2003-07-31 22:41
5056 Re:needs to be declared final?? Eva 156 2003-08-03 09:06
4985 Re:needs to be declared final?? missee 93 2003-08-03 23:17
4914 Re:needs to be declared final?? missee 494 2003-08-03 23:32
8745 Re:needs to be declared final?? Duncan 1616 2003-08-04 00:21
4873 Re:needs to be declared final?? Eva 194 2003-08-04 00:18
5846 Re:needs to be declared final?? Duncan 470 2003-08-04 00:26
4813 Re:needs to be declared final?? missee 24 2003-08-04 01:26
4877 Re:needs to be declared final?? Eva 14 2003-08-04 03:31
5022 Re:needs to be declared final?? worookie 41 2003-07-31 23:57
4917 Re:needs to be declared final?? missee 1454 2003-08-01 00:53
7521 Re:needs to be declared final?? Duncan 283 2003-08-01 01:58
4942 Re:needs to be declared final?? missee 1540 2003-08-01 02:37
4902 Re:needs to be declared final?? Eva 209 2003-08-01 04:07
4979 Re:needs to be declared final?? missee 1710 2003-08-01 11:33
6022 Re:needs to be declared final?? Duncan 1356 2003-08-01 14:06
4933 Re:needs to be declared final?? missee 3388 2003-08-02 14:46
6651 Re:needs to be declared final?? Duncan 355 2003-08-02 15:03
4867 Re:needs to be declared final?? missee 247 2003-08-02 15:14
5478 Re:needs to be declared final?? Duncan 716 2003-08-02 22:31
4935 Re:needs to be declared final?? missee 177 2003-08-03 02:12
» JWorld@TW »  Java SE 討論區

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

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8