JInternalFrame 图像显示;
我尝试向 JInternalFrame 添加图像。我的paint()看起来像这样:
public void paint (Graphics g) {
//this should draw the loaded image
if (bufferedImage != null) {
g.drawImage(bufferedImage, getSize().width/2 - bufferedImage.getWidth()/2,
getInsets().top+20, this);
}
}
图像确实加载并显示,但窗口标题栏(应该有名称、最小值、最大值和关闭的标题栏)消失了。当我将鼠标移动到应有的位置时,最小/最大/关闭按钮会重新出现,当我将鼠标移动到标题栏上时,我可以拖动 整个窗户。
我应该使用其他方法来代替 Paint() 方法吗?
谢谢
I tried adding an image to JInternalFrame. my paint() looks like this:
public void paint (Graphics g) {
//this should draw the loaded image
if (bufferedImage != null) {
g.drawImage(bufferedImage, getSize().width/2 - bufferedImage.getWidth()/2,
getInsets().top+20, this);
}
}
The image does load and display, but the window title bar (the one that should have the name, min, max and close) disappears. The min/max/close buttons reappear when I move the mouse to where they should be, and when I move the mouse over the title bar I can drag
the whole window.
Should I be using something else instead of the paint() method?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非您有充分的理由直接绘制到
JInternalFrame
中,否则为什么不创建一个new JLabel(new ImageIcon(bufferedimage))
并仅使用add()
> 它到JInternalFrame
?一个例子:
Unless you have good reason to directly draw into the
JInternalFrame
, why not create anew JLabel(new ImageIcon(bufferedimage))
and justadd()
it to theJInternalFrame
?An example: