Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JWindow clipping  RSS feed

 
shawn larkin
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it possible to specify a clip region for JWindow, if you wanted to build an app that's round for example?
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The clip regions in Java are driven with x,y,width,height, co-ordinates so you won't get a round clip there.
Why not get a Graphics2D image that has a transparent circle in the center and place it in a glasspane in front of your applicacion?
Another option would be to customise the componentUI classes used and have them draw circular/eliptical components. Layout management should give you some sleepless nights
Bye,
Terry
 
shawn larkin
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the quick reply.
 
shawn larkin
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this mean I can't specify a clip region for my JWindow even if I use a Polygon shape for example as the clip? :roll:
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can specify a clip region, but the window the clip region is drawn on will still be a rectangular JWindow. (So you'll get a rectangular area behind the clip region of whatever color the JWindow is set to.)

The only way to do this is use JNI (or use third party libraries that use JNI...), there have been a few posts on this, and links to third party libraries in them, if you just search JavaRanch...

Here's the most recent...

-Nate
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!