如何处理超大的JDialog [英] How to handle oversized JDialog

查看:97
本文介绍了如何处理超大的JDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个JDialog,它将分为三个部分,一个部分位于另一个顶部:客户常规信息,客户地址列表和订单列表.

客户地址列表可能会任意增大,这会导致对话框超出屏幕高度.

因此,在显示pack()之前调用pack()不起作用,因为压缩后的对话框高度对于屏幕高度仍然太大.

这需要滚动窗格.但是我必须设置对话框的首选大小才能利用它,并且为它定义大小取决于显示分辨率.我不确定该怎么做.

我应该如何处理这种情况?

解决方案

首先,可以使用Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();获取屏幕尺寸,然后按比例调整对话框大小(并将内容放置在JScrollPane中). /p>

第二,我建议在商品上添加某种折叠,这样您就只会看到您真正感兴趣的商品.

I'm developing a JDialog which will have three sections, one on the top of the other: customer general information, list of customer addresses and list of orders.

The list of customer addresses may grow arbitrarily large and this causes the dialog to grow beyond the screen height.

Thus, calling pack() before displaying it does not work because the packed dialog height is still too big for the screen height.

This calls for a scroll pane. But I would have to set the dialog's preferred size to take advantage of it, and defining a size for it depends on the display resolution. I'm not sure how to do that.

How should I handle this scenario?

解决方案

First off, you can use Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); to get the screen size and then size the dialog proportionally (and place the content in a JScrollPane).

Second, I'd suggest adding some kind of collapse on items so you only see the ones you are actually interested in.

这篇关于如何处理超大的JDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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