Java-是否可以在JScrollPane中放置JLayeredPane? [英] Java - Is it possible to put a JLayeredPane inside JScrollPane?

查看:92
本文介绍了Java-是否可以在JScrollPane中放置JLayeredPane?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将JLayeredPane放在JScrollPane中时,得到的是空白窗口(带有白色背景),而不是我尝试呈现的内容(它可以是图像,按钮,画布).有谁知道布局管理器可能会引起问题的问题?有可能吗?

when I try putting my JLayeredPane inside a JScrollPane I get a blank window (with white background) instead of the content I am trying to render (it could be an image, a button, a canvas). Does anyone know of a problem with layout managers that might cause it? Is it possible?

多亏了camickr的帮助,我现在可以将JLayeredPane放在JScrollPane中,尽管现在我遇到了另一个问题:

thanks to camickr help, I can now put a JLayeredPane inside a JScrollPane, though now I am facing a different problem:

我使用的是非常大的图像,并且试图将其放入JScrollPane内的JLayeredPane中.由于某种原因,当我使用这个大图像时(我没有收到堆溢出异常),我得到了空白(白屏).有没有人经历过这样的事情?

I am using a very large image and I am trying to put it inside my JLayeredPane that's inside the JScrollPane. From some reason when I use this large image (I am not receiving a heap overflow exception) I get this blank (white screen). Has anyone experienced something like this?

推荐答案

阅读如何使用分层窗格作为工作示例.

更改以下行:

// add(layeredPane);
add(new JScrollPane(layeredPane));

这篇关于Java-是否可以在JScrollPane中放置JLayeredPane?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆