2

Can I place an image outside JFrame?

I am developing an app, and I wanted to make the Gui good looking and some part of the buttons should go outside. Is there a way to do this?

enter image description here

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Aby Abraham
  • 354
  • 3
  • 9

2 Answers2

6

Yes, but it's not going to be easy, as you going to constantly need to monitor the position of the parent frame in order to maintain the position of the child window.

Essentially, what you can do is create a second, undecorated and transparent window. You would need to align and size the window next to the parent window.

On to this child window, you would need to then add a transparent component which would act as your primary container.

Take a look at How to Create Translucent and Shaped Windows for more details

For example:

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • However, the alignment part is extremely tricky, taking into account varying window borders and chromes between operating systems and Swing L&Fs. – APerson Jul 04 '14 at 03:13
  • @APerson Hmmm...`frame.getLocation().x + frame.getSize().width` will work, as these are values of outside border. Frame decorations are painted inside this area...the tricky part, IMHO, is knowing when the window is moved :P – MadProgrammer Jul 04 '14 at 03:15
1

No; the Swing framework doesn't handle painting outside the root component.

APerson
  • 8,140
  • 8
  • 35
  • 49