java - Transparent Frame works correctly in Windows, but not in Linux -
the following code results in transparent window in windows (8.1), opaque window in ubuntu (14.04). how can achieve transparent window red outline in ubuntu 14.04?
my goal create undecorated window 'rounded (transparent) edges', setopacity() method won't since affect full window, though work on both operating systems.
public static void main(string[] args) { jframe f = new jframe(); f.setundecorated(true); f.setbackground(new color(0,255,0,0)); f.setsize(512, 512); f.add(new jpanel() { @override protected void paintcomponent(graphics g) { g.setcolor(color.red); g.drawrect(0, 0, 511, 511); } }); f.setvisible(true); }
i've found source of problem. related having multi-monitor setup in ubuntu. regardless, here's solution--which cause work on favored monitor:
add following code before setvisible() call:
f.setlocationrelativeto(null);
i think reason failed because frame may have been rendered on secondary monitor first (due different resolutions per monitor?), may have resulted in drawing error.
thank input. appreciated! :)
Comments
Post a Comment