Java:透明文本区域 +绘制背景
我的问题很简单。 JTextArea 可以设置为透明,但不能完全不可见吗?另外,如果可能的话,如何在其后面绘制图像(先绘制图像,然后在其上方绘制透明文本区域)?
My question here is fairly simple. Can JTextArea's be set to transparent, but not completely invisible? Also, if it's possible, how can I draw an image behind it (draw the image first, and then draw the transparent text area overtop of it)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1) 重写 JTextArea 的 PaintComponent() 方法,如下所示:
2) 创建文本区域时,您需要为其提供透明背景:
1) Override the paintComponent() method of the JTextArea something like:
2) When you create the text area you will need to give it a transparent background:
您也可以这样做:
jscrollpane 是 jtextarea 的直接父组件。
You could also do this:
jscrollpane is the immediate parent component of the jtextarea.