问题
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?
回答1:
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:
- How to draw images on transparent window?
- How to make a transparent JFrame but keep everything else the same?
- Creating a JFrame you can click through
回答2:
No; the Swing framework doesn't handle painting outside the root component.
来源:https://stackoverflow.com/questions/24566111/can-i-place-image-outside-jframe