2016-06-01 4 views
1

간단한 문제이지만 왜 작동하지 않는 지 잘 모릅니다. 이전에 나는 똑같이 해왔고 항상 효과가 있었지만 지금은 내가하는 일을하지 않습니다. bgImage를 설정했지만 어떻게 든 작동하지 않습니다. "group"이라는 이미지를 Button으로 설정하면 munuIcon1 = new Button (그룹)으로 동작합니다. 그러나 다음은배경으로 이미지 설정이 작동하지 않습니다.

Image group = theme.getImage("group.png").scaledWidth(imgWidth/3 - 10); 
    Button menuIcon1 = new Button(); 
    menuIcon1.setUIID("menuButtonzz"); 
    menuIcon1.setPreferredSize(new Dimension(150,150)); 
    menuIcon1.getUnselectedStyle().setBgImage(group);//tried getAllStyles() too 

    //tried couple of things but doesn't work 
    menuIcon1.getAllStyles().setBackgroundType(Style.BACKGROUND_IMAGE_SCALED); 
    menuIcon1.getAllStyles().setBgTransparency(255);//tried value to 0 as well 

답변

0

이 먼저 당신이 구현하고자하는 것을 효과적으로이다 ScaledImageButton을 사용하는 것이 좋습니다 것입니다 빈 양식을 제공합니다.

ButtonButton 효과적으로 공백이 경우 빈 라벨을 &을 숨기는 특별한 경우가 있습니다 Label에서 유래.

이전의 방법으로는 new Button(" ")을 생성하는 데는 두 가지 방법이 있습니다. 이렇게하면 Button이 비어 있지 않으므로 렌더링됩니다.

더 새로운 방법은 setShowEvenIfBlank(true)입니다.

관련 문제