JSplitPane SetDividerLocation问题 [英] JSplitPane SetDividerLocation Problem

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

问题描述

我有一个JSplitPane,在显示时应将窗格拆分50%.

I have a JSplitPane which when shown should split the pane by 50%.

现在,将setDividerLocation的参数设为0.5(如建议的那样),Java似乎将其视为普通数字而不是百分比.如图所示,分隔符几乎没有在窗格的中间,而是在左窗格的开始处(窗格是垂直拆分的). 有什么解决方法吗?

Now on giving an argument of 0.5 (as suggested) to setDividerLocation, Java seems to treat it as a normal number instead of a percentage. As in, the divider, instead of going to the middle of the pane, is almost at the start of the left pane (the pane is vertically split). Any work arounds?

推荐答案

我错过了什么吗?这个问题似乎有很多令人费解的答案...但是我认为简单的setResizeWeight(0.5)可以解决问题...

Am I missing something? There seem to be a lot of rather convoluted answers to this question... but I think a simple setResizeWeight(0.5) would solve the issue ... it's described in the SplitPane Tutorial

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

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