2012-02-11 118 views
1

如何使透明背景的圖像按鈕?三重播放按鈕:透明背景的圖像按鈕

默認背景爲灰色,我創建的按鈕與空文本和的setIcon,這樣的事情:

backButton = new Button(); //"Back"); 
    backButton.setIcon(backIcon); 

    iface.createRoot(AxisLayout.vertical(), ROOT, modeLayer). 
      setStyles(make(VALIGN.top, HALIGN.right)). 
      setBounds(0, 0, width, height). 
      add(backButton); 

但無法弄清楚如何使按鈕,可從API /源透明碼。

任何幫助/提示非常感謝。

+0

來自Michael的很好答案:https://groups.google.com/forum/?fromgroups#!topic/ooo-libs/FaaANe7LgC4 – mamamia 2012-02-11 17:46:49

回答

2

您想使用Style.BACKGROUND

如果你想在你的整個UI所有按鈕有一個空的背景,然後配置你的根樣式表像這樣:

Stylesheet ROOT = SimpleStyles.newSheetBuilder(). 
add(Button.class, Styles.none(). 
    add(Style.BACKGROUND.is(new NullBackground())). 
    addSelected(Style.BACKGROUND.is(new NullBackground()))). 
create(); 

Root root = iface.createRoot(AxisLayout.vertical(), ROOT, modeLayer).etc(). 

如果你只是想要一個特定的按鈕,有一個空白的背景下, 其配置在按鈕上:

Styles blankBg = Styles.none(). 
    add(Style.BACKGROUND.is(new NullBackground())) 
    addSelected(Style.BACKGROUND.is(new NullBackground()); 

Button backButton = new Button().addStyles(blankBg).setIcon(backIcon); 

還要注意SimpleStyles定義了按鈕的背景。如果你從一個完全空白的樣式表開始,你可以省略你的按鈕的背景定義,它們將是空白的。