2016-06-12 4 views
0

나는 더 큰 직사각형의 육각형 보드를 가지고 있습니다. 각 육각형을 가리킬 때마다버튼 위로 마우스를 가져 가면 해당 버튼이 전면에 나타납니다.

g.setColor(getBackground()); 
g.fillPolygon(hexagon); 
g.setColor(getForeground()); 
g.drawPolygon(hexagon); 

은 전체 직사각형 다른 육각형 겹치는 가장자리 주위에 발생하는 흰색 사각형 결과 전면하게된다. http://prntscr.com/bfiixt < - 문제의 예.

이 배경을 투명하게 만들면 어떻게 문제가 생기지 않게 할 수 있습니까? 아니면 버튼을 앞으로 가져 가지 않게하려면 어떻게해야합니까? 감사합니다. . 이 코드를 추가하여 수정

FontMetrics fm = getFontMetrics(getFont()); 
     Rectangle viewR = getBounds(); 
     Rectangle iconR = new Rectangle(); 
     Rectangle textR = new Rectangle(); 

     SwingUtilities.layoutCompoundLabel(this, fm, getText(), null, SwingUtilities.CENTER, 
       SwingUtilities.CENTER, SwingUtilities.BOTTOM, SwingUtilities.CENTER, viewR, iconR, textR, 0); 

     Point location = getLocation(); 
     g.drawString(getText(), textR.x - location.x, textR.y - location.y + fm.getAscent()); 
+0

도움이 되었습니까? – SomeDude

+0

@svasa 이것을 편집하고 코드를 추가했습니다. – oodle600

답변

0

:이 문제를 가진 다른 사람

btn.setContentAreaFilled(false); 
btn.setFocusPainted(false); 
btn.setBorderPainted(false); 

,이 투명 물체 내부의 육각형 외부의 어떤 변경하여 고정.

관련 문제