Can I place image outside JFrame?

為{幸葍}努か 提交于 2019-12-24 04:12:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!