JSplitPane精确分裂50% [英] JSplitPane splitting 50% precisely

查看:113
本文介绍了JSplitPane精确分裂50%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Swing中,
是让JSplitPane分割两个jpanels的最佳方式,每个jpanels的大小分别为50%。

In Swing, what's the best way to make the JSplitPane to split two jpanels with 50% size each.

看起来好像我不喜欢在面板上设置首选尺寸,它总是使第一个面板几乎不可见(2%),第二个面板(98%)

It looks like if I don't set preferred sizes on the panels it always makes the first panel almost invisible (2%) and the second one (98%)

提前致谢

推荐答案

使用

setResizeWeight (。5d);


[...]值为0,默认值为0表示右/底组件获取所有额外空间(左/顶组件固定),其中值为1指定左/顶组件获取所有额外空间(右/底组件固定)。 [...]

[...] A value of 0, the default, indicates the right/bottom component gets all the extra space (the left/top component acts fixed), where as a value of 1 specifies the left/top component gets all the extra space (the right/bottom component acts fixed). [...]

这篇关于JSplitPane精确分裂50%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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